Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)25809690.625257.0CPython 2.750726246.875455.5475067714816Nuitka (master)50846403.125455.4326121347811Nuitka (develop)50768559.375455.5072936486364Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000280000280000300000300000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)30971890.625257.0CPython 3.549470246.875464.644646469965Nuitka (master)45148403.125468.09305015430914Nuitka (develop)50132559.375464.11645506805945Nuitka (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         assert( old != NULL );
270         var_local_value2 = tmp_assign_source_3;
271         Py_DECREF( old );
272     } 269     {
273  
274     }
275     {
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