Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)995590.625479.5401148520816CPython 2.799982246.875257.29623630051196Nuitka (master)100006403.125257.2369890404095Nuitka (develop)100102559.375257.0Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1188391.46153846153847474.7442018013194CPython 3.599978249.15384615384613257.0Nuitka (master)99094406.8461538461538259.1849806957531Nuitka (develop)97964564.5384615384615261.9779990059352Nuitka (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
240     { 240     {
241         goto branch_no_1; 241         goto branch_no_1;
242     } 242     }
243     branch_yes_1:; 243     branch_yes_1:;
244     { 244     {
n 245     CHECK_OBJECT( var_local_value ); n
246     Py_DECREF( var_local_value );
247     var_local_value = NULL;
248  
249     }
250     {
251     PyObject *tmp_assign_source_3; 245     PyObject *tmp_assign_source_3;
252     PyObject *tmp_mvar_value_4; 246     PyObject *tmp_mvar_value_4;
253     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 );
254 248
255     if (unlikely( tmp_mvar_value_4 == NULL )) 249     if (unlikely( tmp_mvar_value_4 == NULL ))
334     } 328     }
335 329
336     tmp_assign_source_5 = tmp_mvar_value_6; 330     tmp_assign_source_5 = tmp_mvar_value_6;
337     { 331     {
338         PyObject *old = var_local_value; 332         PyObject *old = var_local_value;
n n 333         assert( old != NULL );
339         var_local_value = tmp_assign_source_5; 334         var_local_value = tmp_assign_source_5;
340         Py_INCREF( var_local_value ); 335         Py_INCREF( var_local_value );
t 341         Py_XDECREF( old ); t 336         Py_DECREF( old );
342     } 337     }
343 338
344     } 339     }
345 340
346 #if 0 341 #if 0