Construct LocalVariableAssign

Performance Diagrams

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