Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000280000280000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)20574975.0334.48130792790755CPython 2.7299726200.0257.0Nuitka (historic)99055325.0422.4474131244999Nuitka (master)99876450.0421.7705224617972Nuitka (develop)99900575.0421.75073515862437Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)26040675.0257.0CPython 3.50200.0504.11538461538464Nuitka (historic)56905325.0450.11470505524215Nuitka (master)50007450.0456.6606445615397Nuitka (develop)56695575.0450.31398706398704Nuitka (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

for x in xrange(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

for x in xrange(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
137     PyTracebackObject *exception_keeper_tb_1; 137     PyTracebackObject *exception_keeper_tb_1;
138     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 138     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
139     PyObject *tmp_assign_source_1; 139     PyObject *tmp_assign_source_1;
140     PyObject *tmp_assign_source_2; 140     PyObject *tmp_assign_source_2;
141     PyObject *tmp_assign_source_3; 141     PyObject *tmp_assign_source_3;
n 142     PyObject *tmp_assign_source_4; n
143     PyObject *tmp_frame_locals; 142     PyObject *tmp_frame_locals;
144     PyObject *tmp_left_name_1; 143     PyObject *tmp_left_name_1;
145     PyObject *tmp_left_name_2; 144     PyObject *tmp_left_name_2;
146     PyObject *tmp_return_value; 145     PyObject *tmp_return_value;
147     PyObject *tmp_right_name_1; 146     PyObject *tmp_right_name_1;
242     var_local_value2 = tmp_assign_source_2; 241     var_local_value2 = tmp_assign_source_2;
243 242
244     tmp_left_name_1 = var_local_value; 243     tmp_left_name_1 = var_local_value;
245 244
246     tmp_right_name_1 = const_int_pos_2; 245     tmp_right_name_1 = const_int_pos_2;
n 247     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 ); n 246     tmp_unused = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 );
248     if ( tmp_assign_source_3 == NULL ) 247     if ( tmp_unused == NULL )
249     { 248     {
250         assert( ERROR_OCCURRED() ); 249         assert( ERROR_OCCURRED() );
251 250
252         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 251         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
253 252
254 253
n 255         exception_lineno = 31; n 254         exception_lineno = 33;
256         goto frame_exception_exit_1; 255         goto frame_exception_exit_1;
257     } 256     }
n 258     { n 257     Py_DECREF( tmp_unused );
259         PyObject *old = var_local_value2;
260         var_local_value2 = tmp_assign_source_3;
261         Py_XDECREF( old );
262     }
263  
264     tmp_left_name_2 = var_local_value; 258     tmp_left_name_2 = var_local_value;
265 259
266     if ( tmp_left_name_2 == NULL ) 260     if ( tmp_left_name_2 == NULL )
267     { 261     {
268 262
276         exception_lineno = 36; 270         exception_lineno = 36;
277         goto frame_exception_exit_1; 271         goto frame_exception_exit_1;
278     } 272     }
279 273
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( tmp_left_name_2, tmp_right_name_2 ); n 275     tmp_assign_source_3 = BINARY_OPERATION_MUL( 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
289         exception_lineno = 36; 283         exception_lineno = 36;
290         goto frame_exception_exit_1; 284         goto frame_exception_exit_1;
291     } 285     }
292     { 286     {
293         PyObject *old = var_local_value2; 287         PyObject *old = var_local_value2;
t 294         var_local_value2 = tmp_assign_source_4; t 288         var_local_value2 = tmp_assign_source_3;
295         Py_XDECREF( old ); 289         Py_XDECREF( old );
296     } 290     }
297 291
298     tmp_return_value = var_local_value; 292     tmp_return_value = var_local_value;
299 293