Construct LocalVariableAssign

Performance Diagrams

Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)20582590.625257.0CPython 2.749976246.875444.1137402012539Nuitka (master)49292403.125444.9349568808454Nuitka (develop)49268559.375444.96377150118195Nuitka (factory)Construct LocalVariableAssignTicks Construct LocalVariableAssign 002000020000400004000060000600008000080000100000100000120000120000140000140000160000160000180000180000200000200000220000220000240000240000260000260000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)26032390.625257.00000000000006CPython 3.557457246.875449.57349375731155Nuitka (master)50303403.125456.3645320502725Nuitka (develop)48976559.375457.6242060528947Nuitka (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
145     PyTracebackObject *exception_keeper_tb_1; 145     PyTracebackObject *exception_keeper_tb_1;
146     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 146     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
147     PyObject *tmp_assign_source_1; 147     PyObject *tmp_assign_source_1;
148     PyObject *tmp_assign_source_2; 148     PyObject *tmp_assign_source_2;
149     PyObject *tmp_assign_source_3; 149     PyObject *tmp_assign_source_3;
n 150     PyObject *tmp_assign_source_4; n
151     PyObject *tmp_left_name_1; 150     PyObject *tmp_left_name_1;
152     PyObject *tmp_left_name_2; 151     PyObject *tmp_left_name_2;
153     PyObject *tmp_return_value; 152     PyObject *tmp_return_value;
154     PyObject *tmp_right_name_1; 153     PyObject *tmp_right_name_1;
155     PyObject *tmp_right_name_2; 154     PyObject *tmp_right_name_2;
249 248
250     tmp_left_name_1 = var_local_value; 249     tmp_left_name_1 = var_local_value;
251 250
252     CHECK_OBJECT( tmp_left_name_1 ); 251     CHECK_OBJECT( tmp_left_name_1 );
253     tmp_right_name_1 = const_int_pos_2; 252     tmp_right_name_1 = const_int_pos_2;
n 254     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 ); n 253     tmp_unused = BINARY_OPERATION_MUL( tmp_left_name_1, tmp_right_name_1 );
255     if ( tmp_assign_source_3 == NULL ) 254     if ( tmp_unused == NULL )
256     { 255     {
257         assert( ERROR_OCCURRED() ); 256         assert( ERROR_OCCURRED() );
258 257
259         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 258         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
260 259
261 260
n 262         exception_lineno = 31; n 261         exception_lineno = 33;
263         type_description_1 = "oo"; 262         type_description_1 = "oo";
264         goto frame_exception_exit_1; 263         goto frame_exception_exit_1;
265     } 264     }
n 266     { n 265     Py_DECREF( tmp_unused );
267         PyObject *old = var_local_value2;
268         var_local_value2 = tmp_assign_source_3;
269         Py_XDECREF( old );
270     }
271  
272     tmp_left_name_2 = var_local_value; 266     tmp_left_name_2 = var_local_value;
273 267
274     if ( tmp_left_name_2 == NULL ) 268     if ( tmp_left_name_2 == NULL )
275     { 269     {
276 270
285         type_description_1 = "oo"; 279         type_description_1 = "oo";
286         goto frame_exception_exit_1; 280         goto frame_exception_exit_1;
287     } 281     }
288 282
289     tmp_right_name_2 = const_int_pos_4; 283     tmp_right_name_2 = const_int_pos_4;
n 290     tmp_assign_source_4 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 ); n 284     tmp_assign_source_3 = BINARY_OPERATION_MUL( tmp_left_name_2, tmp_right_name_2 );
291     if ( tmp_assign_source_4 == NULL ) 285     if ( tmp_assign_source_3 == NULL )
292     { 286     {
293         assert( ERROR_OCCURRED() ); 287         assert( ERROR_OCCURRED() );
294 288
295         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); 289         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
296 290
299         type_description_1 = "oo"; 293         type_description_1 = "oo";
300         goto frame_exception_exit_1; 294         goto frame_exception_exit_1;
301     } 295     }
302     { 296     {
303         PyObject *old = var_local_value2; 297         PyObject *old = var_local_value2;
t 304         var_local_value2 = tmp_assign_source_4; t 298         var_local_value2 = tmp_assign_source_3;
305         Py_XDECREF( old ); 299         Py_XDECREF( old );
306     } 300     }
307 301
308     tmp_return_value = var_local_value; 302     tmp_return_value = var_local_value;
309 303