Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)888690.625482.15671153846154CPython 2.7100000246.875257.0Nuitka (master)100000403.125257.0Nuitka (develop)100000559.375257.0Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)1156190.625475.546375CPython 3.8100000246.875257.0Nuitka (master)100000403.125257.0Nuitka (develop)100000559.375257.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
211         } else { 211         } else {
212             goto branch_no_1; 212             goto branch_no_1;
213         } 213         }
214     } 214     }
215     branch_yes_1:; 215     branch_yes_1:;
n 216     CHECK_OBJECT(var_local_value); n
217     Py_DECREF(var_local_value);
218     var_local_value = NULL;
219  
220     { 216     {
221         PyObject *tmp_assign_source_3; 217         PyObject *tmp_assign_source_3;
222         tmp_assign_source_3 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[2]); 218         tmp_assign_source_3 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[2]);
223 219
224         if (unlikely(tmp_assign_source_3 == NULL)) { 220         if (unlikely(tmp_assign_source_3 == NULL)) {
278             type_description_1 = "oo"; 274             type_description_1 = "oo";
279             goto frame_exception_exit_1; 275             goto frame_exception_exit_1;
280         } 276         }
281         { 277         {
282             PyObject *old = var_local_value; 278             PyObject *old = var_local_value;
n n 279             assert(old != NULL);
283             var_local_value = tmp_assign_source_5; 280             var_local_value = tmp_assign_source_5;
284             Py_INCREF(var_local_value); 281             Py_INCREF(var_local_value);
t 285             Py_XDECREF(old); t 282             Py_DECREF(old);
286         } 283         }
287 284
288     } 285     }
289 286
290 #if 0 287 #if 0