Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)984891.46153846153847479.7663130398107CPython 2.799256249.15384615384613258.7060174032439Nuitka (master)99928406.8461538461538257.04450480182373Nuitka (develop)99946564.5384615384615257.0Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1191190.625475.75409512246824CPython 3.5100054246.875265.87674311389407Nuitka (master)103782403.125257.0Nuitka (develop)99972559.375266.0719933647898Nuitka (factory)Construct LocalVariableDeletionTicks

Source Code with Construct

module_value1 = 1000
module_value2 = None
module_value3 = None

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = module_value1

    # Use writing to global variable as access method.
    global module_value2, module_value3

    module_value2 = local_value

    if module_value2 is None:
# construct_begin
        del local_value
# construct_end

        another_local_value = module_value3

    module_value2 = module_value1

    local_value = module_value3
    return local_value

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000
module_value2 = None
module_value3 = None

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = module_value1

    # Use writing to global variable as access method.
    global module_value2, module_value3

    module_value2 = local_value

    if module_value2 is None:
# construct_begin



        another_local_value = module_value3

    module_value2 = module_value1

    local_value = module_value3
    return local_value

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
32 32
33     module_value2 = local_value 33     module_value2 = local_value
34 34
35     if module_value2 is None: 35     if module_value2 is None:
36 # construct_begin 36 # construct_begin
t 37         del local_value t 37  
38 # construct_end 38  
39 39
40         another_local_value = module_value3 40         another_local_value = module_value3
41 41
42     module_value2 = module_value1 42     module_value2 = module_value1
43 43

Context Diff of Generated Code


Construct
Baseline
239         else 239         else
240         { 240         {
241             goto branch_no_1; 241             goto branch_no_1;
242         } 242         }
243         branch_yes_1:; 243         branch_yes_1:;
n 244         CHECK_OBJECT( var_local_value ); n
245         Py_DECREF( var_local_value );
246         var_local_value = NULL;
247  
248         { 244         {
249             PyObject *tmp_assign_source_3; 245             PyObject *tmp_assign_source_3;
250             PyObject *tmp_mvar_value_4; 246             PyObject *tmp_mvar_value_4;
251             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 247             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
252 248
331         } 327         }
332 328
333         tmp_assign_source_5 = tmp_mvar_value_6; 329         tmp_assign_source_5 = tmp_mvar_value_6;
334         { 330         {
335             PyObject *old = var_local_value; 331             PyObject *old = var_local_value;
n n 332             assert( old != NULL );
336             var_local_value = tmp_assign_source_5; 333             var_local_value = tmp_assign_source_5;
337             Py_INCREF( var_local_value ); 334             Py_INCREF( var_local_value );
t 338             Py_XDECREF( old ); t 335             Py_DECREF( old );
339         } 336         }
340 337
341     } 338     }
342 339
343 #if 0 340 #if 0