Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 0010000100002000020000300003000040000400005000050000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)970591.46153846153847456.1560435824624CPython 2.750006249.15384615384613257.0Nuitka (master)49922406.8461538461538257.4151040336699Nuitka (develop)49404564.5384615384615259.97491224130033Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 0010000100002000020000300003000040000400005000050000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1232991.46153846153847443.22794752910863CPython 3.550026249.15384615384613257.0592626526917Nuitka (master)50036406.8461538461538257.009877108782Nuitka (develop)50038564.5384615384615257.0Nuitka (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
233             goto branch_yes_1; 233             goto branch_yes_1;
234         } else { 234         } else {
235             goto branch_no_1; 235             goto branch_no_1;
236         } 236         }
237         branch_yes_1:; 237         branch_yes_1:;
n 238         CHECK_OBJECT(var_local_value); n
239         Py_DECREF(var_local_value);
240         var_local_value = NULL;
241  
242         { 238         {
243             PyObject *tmp_assign_source_3; 239             PyObject *tmp_assign_source_3;
244             PyObject *tmp_mvar_value_4; 240             PyObject *tmp_mvar_value_4;
245             tmp_mvar_value_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3); 241             tmp_mvar_value_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3);
246 242
322         } 318         }
323 319
324         tmp_assign_source_5 = tmp_mvar_value_6; 320         tmp_assign_source_5 = tmp_mvar_value_6;
325         { 321         {
326             PyObject *old = var_local_value; 322             PyObject *old = var_local_value;
n n 323             assert(old != NULL);
327             var_local_value = tmp_assign_source_5; 324             var_local_value = tmp_assign_source_5;
328             Py_INCREF(var_local_value); 325             Py_INCREF(var_local_value);
t 329             Py_XDECREF(old); t 326             Py_DECREF(old);
330         } 327         }
331 328
332     } 329     }
333 330
334 #if 0 331 #if 0