Construct LocalVariableAssign

Performance Diagrams

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