Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)25809690.625257.0CPython 2.749832246.875456.4034718149001Nuitka (master)49904403.125456.33453503287984Nuitka (develop)49910559.375456.3287903010448Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000280000280000300000300000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)30971890.625257.0CPython 3.547190246.875466.4637951049267Nuitka (master)48654403.125465.2957101919513Nuitka (develop)52386559.375462.3180511105139Nuitka (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     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     }
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 n 267     Py_DECREF( tmp_op_mult_res_1 );
267     { 268     }
268         PyObject *old = var_local_value2;
269         var_local_value2 = tmp_assign_source_3;
270         Py_XDECREF( old );
271     } 269     {
272  
273     }
274     {
275     PyObject *tmp_assign_source_4; 270     PyObject *tmp_assign_source_3;
276     PyObject *tmp_left_name_2; 271     PyObject *tmp_left_name_2;
277     PyObject *tmp_right_name_2; 272     PyObject *tmp_right_name_2;
278     if ( var_local_value == NULL ) 273     if ( var_local_value == NULL )
279     { 274     {
280 275
290         goto frame_exception_exit_1; 285         goto frame_exception_exit_1;
291     } 286     }
292 287
293     tmp_left_name_2 = var_local_value; 288     tmp_left_name_2 = var_local_value;
294     tmp_right_name_2 = const_int_pos_4; 289     tmp_right_name_2 = const_int_pos_4;
n 295     tmp_assign_source_4 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 ); n 290     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 );
296     if ( tmp_assign_source_4 == NULL ) 291     if ( tmp_assign_source_3 == NULL )
297     { 292     {
298         assert( ERROR_OCCURRED() ); 293         assert( ERROR_OCCURRED() );
299 294
300         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 295         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
301 296
304         type_description_1 = "oo"; 299         type_description_1 = "oo";
305         goto frame_exception_exit_1; 300         goto frame_exception_exit_1;
306     } 301     }
307     { 302     {
308         PyObject *old = var_local_value2; 303         PyObject *old = var_local_value2;
t 309         var_local_value2 = tmp_assign_source_4; t 304         var_local_value2 = tmp_assign_source_3;
310         Py_XDECREF( old ); 305         Py_XDECREF( old );
311     } 306     }
312 307
313     } 308     }
314     { 309     {