Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 0010000100002000020000300003000040000400005000050000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)970591.46153846153847456.88705047414186CPython 2.750780249.15384615384613257.0Nuitka (master)50012406.8461538461538260.7373890386888Nuitka (develop)50750564.5384615384615257.1459917593238Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 001000010000200002000030000300004000040000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1232991.46153846153847443.14020995815616CPython 3.549966249.15384615384613257.0Nuitka (master)49966406.8461538461538257.0Nuitka (develop)49936564.5384615384615257.1483701224525Nuitka (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
229             goto branch_yes_1; 229             goto branch_yes_1;
230         } else { 230         } else {
231             goto branch_no_1; 231             goto branch_no_1;
232         } 232         }
233         branch_yes_1:; 233         branch_yes_1:;
n 234         CHECK_OBJECT(var_local_value); n
235         Py_DECREF(var_local_value);
236         var_local_value = NULL;
237  
238         { 234         {
239             PyObject *tmp_assign_source_3; 235             PyObject *tmp_assign_source_3;
240             PyObject *tmp_mvar_value_4; 236             PyObject *tmp_mvar_value_4;
241             tmp_mvar_value_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3); 237             tmp_mvar_value_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3);
242 238
315         } 311         }
316 312
317         tmp_assign_source_5 = tmp_mvar_value_6; 313         tmp_assign_source_5 = tmp_mvar_value_6;
318         { 314         {
319             PyObject *old = var_local_value; 315             PyObject *old = var_local_value;
n n 316             assert(old != NULL);
320             var_local_value = tmp_assign_source_5; 317             var_local_value = tmp_assign_source_5;
321             Py_INCREF(var_local_value); 318             Py_INCREF(var_local_value);
t 322             Py_XDECREF(old); t 319             Py_DECREF(old);
323         } 320         }
324 321
325     } 322     }
326 323
327 #if 0 324 #if 0