Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)25709790.625257.0CPython 2.749136246.875456.887056247253Nuitka (master)50708403.125455.37608807331327Nuitka (develop)50750559.375455.3357186946202Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 0010000100002000020000300003000040000400005000050000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5767891.46153846153847257.0CPython 3.550142249.15384615384613289.2872072273924Nuitka (master)52822406.8461538461538277.80502631319234Nuitka (develop)46976564.5384615384615302.85160453125707Nuitka (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
244         assert( var_local_value2 == NULL ); 244         assert( var_local_value2 == NULL );
245         Py_INCREF( tmp_assign_source_2 ); 245         Py_INCREF( tmp_assign_source_2 );
246         var_local_value2 = tmp_assign_source_2; 246         var_local_value2 = tmp_assign_source_2;
247     } 247     }
248     { 248     {
n 249         PyObject *tmp_assign_source_3; n
250         PyObject *tmp_left_name_1; 249         PyObject *tmp_left_name_1;
251         PyObject *tmp_right_name_1; 250         PyObject *tmp_right_name_1;
n n 251         PyObject *tmp_op_mult_res_1;
252         CHECK_OBJECT( var_local_value ); 252         CHECK_OBJECT( var_local_value );
253         tmp_left_name_1 = var_local_value; 253         tmp_left_name_1 = var_local_value;
254         tmp_right_name_1 = const_int_pos_2; 254         tmp_right_name_1 = const_int_pos_2;
n 255         tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 ); n 255         tmp_op_mult_res_1 = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 );
256         if ( tmp_assign_source_3 == NULL ) 256         if ( tmp_op_mult_res_1 == NULL )
257         { 257         {
258             assert( ERROR_OCCURRED() ); 258             assert( ERROR_OCCURRED() );
259 259
260             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 260             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
261 261
262 262
n 263             exception_lineno = 31; n 263             exception_lineno = 33;
264             type_description_1 = "oo"; 264             type_description_1 = "oo";
265             goto frame_exception_exit_1; 265             goto frame_exception_exit_1;
266         } 266         }
n 267         { n 267         Py_DECREF( tmp_op_mult_res_1 );
268             PyObject *old = var_local_value2;
269             assert( old != NULL );
270             var_local_value2 = tmp_assign_source_3;
271             Py_DECREF( old );
272         }
273  
274     }
275     { 268     }
269     {
276         PyObject *tmp_assign_source_4; 270         PyObject *tmp_assign_source_3;
277         PyObject *tmp_left_name_2; 271         PyObject *tmp_left_name_2;
278         PyObject *tmp_right_name_2; 272         PyObject *tmp_right_name_2;
279         CHECK_OBJECT( var_local_value ); 273         CHECK_OBJECT( var_local_value );
280         tmp_left_name_2 = var_local_value; 274         tmp_left_name_2 = var_local_value;
281         tmp_right_name_2 = const_int_pos_4; 275         tmp_right_name_2 = const_int_pos_4;
n 282         tmp_assign_source_4 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 ); n 276         tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 );
283         if ( tmp_assign_source_4 == NULL ) 277         if ( tmp_assign_source_3 == NULL )
284         { 278         {
285             assert( ERROR_OCCURRED() ); 279             assert( ERROR_OCCURRED() );
286 280
287             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 281             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
288 282
292             goto frame_exception_exit_1; 286             goto frame_exception_exit_1;
293         } 287         }
294         { 288         {
295             PyObject *old = var_local_value2; 289             PyObject *old = var_local_value2;
296             assert( old != NULL ); 290             assert( old != NULL );
t 297             var_local_value2 = tmp_assign_source_4; t 291             var_local_value2 = tmp_assign_source_3;
298             Py_DECREF( old ); 292             Py_DECREF( old );
299         } 293         }
300 294
301     } 295     }
302 296