Construct LocalVariableAssign

Performance Diagrams

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