Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)25809690.625257.0CPython 2.750000246.875456.2426193235195Nuitka (master)49964403.125456.2770877145296Nuitka (develop)49976559.375456.26559825085957Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000280000280000300000300000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)30971890.625257.0CPython 3.549898246.875464.3031571648055Nuitka (master)49918403.125464.2871997206392Nuitka (develop)50118559.375464.12762527897587Nuitka (factory)Construct LocalVariableAssignTicks

Source Code with Construct

module_value1 = 1000
module_value2 = 50

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = module_value1
    local_value2 = module_value2

# construct_begin
    local_value2 = local_value * 2
# construct_alternative



    local_value2 = local_value * 4

    return local_value

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000
module_value2 = 50

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = module_value1
    local_value2 = module_value2

# construct_begin

# construct_alternative
    local_value * 2
# construct_end

    local_value2 = local_value * 4

    return local_value

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
26 26
27     local_value = module_value1 27     local_value = module_value1
28     local_value2 = module_value2 28     local_value2 = module_value2
29 29
30 # construct_begin 30 # construct_begin
n 31     local_value2 = local_value * 2 n 31  
32 # construct_alternative 32 # construct_alternative
t 33   t 33     local_value * 2
34   34 # construct_end
35 35
36     local_value2 = local_value * 4 36     local_value2 = local_value * 4
37 37
38     return local_value 38     return local_value
39 39

Context Diff of Generated Code


Construct
Baseline
240     Py_INCREF( tmp_assign_source_2 ); 240     Py_INCREF( tmp_assign_source_2 );
241     var_local_value2 = tmp_assign_source_2; 241     var_local_value2 = tmp_assign_source_2;
242 242
243     } 243     }
244     { 244     {
n 245     PyObject *tmp_assign_source_3; n
246     PyObject *tmp_left_name_1; 245     PyObject *tmp_left_name_1;
247     PyObject *tmp_right_name_1; 246     PyObject *tmp_right_name_1;
248     tmp_left_name_1 = var_local_value; 247     tmp_left_name_1 = var_local_value;
249 248
250     CHECK_OBJECT( tmp_left_name_1 ); 249     CHECK_OBJECT( tmp_left_name_1 );
251     tmp_right_name_1 = const_int_pos_2; 250     tmp_right_name_1 = const_int_pos_2;
n 252     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 ); n 251     tmp_unused = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 );
253     if ( tmp_assign_source_3 == NULL ) 252     if ( tmp_unused == NULL )
254     { 253     {
255         assert( ERROR_OCCURRED() ); 254         assert( ERROR_OCCURRED() );
256 255
257         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 256         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
258 257
259 258
n 260         exception_lineno = 31; n 259         exception_lineno = 33;
261         type_description_1 = "oo"; 260         type_description_1 = "oo";
262         goto frame_exception_exit_1; 261         goto frame_exception_exit_1;
263     } 262     }
n n 263     Py_DECREF( tmp_unused );
264     { 264     }
265         PyObject *old = var_local_value2;
266         var_local_value2 = tmp_assign_source_3;
267         Py_XDECREF( old );
268     } 265     {
269  
270     }
271     {
272     PyObject *tmp_assign_source_4; 266     PyObject *tmp_assign_source_3;
273     PyObject *tmp_left_name_2; 267     PyObject *tmp_left_name_2;
274     PyObject *tmp_right_name_2; 268     PyObject *tmp_right_name_2;
275     tmp_left_name_2 = var_local_value; 269     tmp_left_name_2 = var_local_value;
276 270
277     if ( tmp_left_name_2 == NULL ) 271     if ( tmp_left_name_2 == NULL )
288         type_description_1 = "oo"; 282         type_description_1 = "oo";
289         goto frame_exception_exit_1; 283         goto frame_exception_exit_1;
290     } 284     }
291 285
292     tmp_right_name_2 = const_int_pos_4; 286     tmp_right_name_2 = const_int_pos_4;
n 293     tmp_assign_source_4 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 ); n 287     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 );
294     if ( tmp_assign_source_4 == NULL ) 288     if ( tmp_assign_source_3 == NULL )
295     { 289     {
296         assert( ERROR_OCCURRED() ); 290         assert( ERROR_OCCURRED() );
297 291
298         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 292         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
299 293
302         type_description_1 = "oo"; 296         type_description_1 = "oo";
303         goto frame_exception_exit_1; 297         goto frame_exception_exit_1;
304     } 298     }
305     { 299     {
306         PyObject *old = var_local_value2; 300         PyObject *old = var_local_value2;
t 307         var_local_value2 = tmp_assign_source_4; t 301         var_local_value2 = tmp_assign_source_3;
308         Py_XDECREF( old ); 302         Py_XDECREF( old );
309     } 303     }
310 304
311     } 305     }
312     { 306     {