Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)986690.625479.7583635094924CPython 2.799910246.875257.45919378934684Nuitka (master)100096403.125257.0Nuitka (develop)99982559.375257.281441354761Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1168890.625475.28788725646757CPython 3.5100192246.875257.0Nuitka (master)99658403.125258.317067384468Nuitka (develop)99538559.375258.6130375832248Nuitka (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         else 240         else
241         { 241         {
242             goto branch_no_1; 242             goto branch_no_1;
243         } 243         }
244         branch_yes_1:; 244         branch_yes_1:;
n 245         CHECK_OBJECT( var_local_value ); n
246         Py_DECREF( var_local_value );
247         var_local_value = NULL;
248  
249         { 245         {
250             PyObject *tmp_assign_source_3; 246             PyObject *tmp_assign_source_3;
251             PyObject *tmp_mvar_value_4; 247             PyObject *tmp_mvar_value_4;
252             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 248             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
253 249
332         } 328         }
333 329
334         tmp_assign_source_5 = tmp_mvar_value_6; 330         tmp_assign_source_5 = tmp_mvar_value_6;
335         { 331         {
336             PyObject *old = var_local_value; 332             PyObject *old = var_local_value;
n n 333             assert( old != NULL );
337             var_local_value = tmp_assign_source_5; 334             var_local_value = tmp_assign_source_5;
338             Py_INCREF( var_local_value ); 335             Py_INCREF( var_local_value );
t 339             Py_XDECREF( old ); t 336             Py_DECREF( old );
340         } 337         }
341 338
342     } 339     }
343 340
344 #if 0 341 #if 0