Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)995591.46153846153847479.51357196816423CPython 2.799916249.15384615384613257.192761565694Nuitka (master)99994406.8461538461538257.0Nuitka (develop)99922564.5384615384615257.1779337529483Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1188390.625474.82506088381666CPython 3.599974246.875257.6901700450088Nuitka (master)100254403.125257.0Nuitka (develop)100120559.375257.3302956643971Nuitka (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
133     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 133     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
134     PyObject *exception_type = NULL; 134     PyObject *exception_type = NULL;
135     PyObject *exception_value = NULL; 135     PyObject *exception_value = NULL;
136     PyTracebackObject *exception_tb = NULL; 136     PyTracebackObject *exception_tb = NULL;
137     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 137     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 138     bool tmp_result; n
139     static struct Nuitka_FrameObject *cache_frame_b6ac8f5c0071b4bb582ad1245036a926 = NULL; 138     static struct Nuitka_FrameObject *cache_frame_b6ac8f5c0071b4bb582ad1245036a926 = NULL;
140     PyObject *tmp_return_value = NULL; 139     PyObject *tmp_return_value = NULL;
141     PyObject *exception_keeper_type_1; 140     PyObject *exception_keeper_type_1;
142     PyObject *exception_keeper_value_1; 141     PyObject *exception_keeper_value_1;
143     PyTracebackObject *exception_keeper_tb_1; 142     PyTracebackObject *exception_keeper_tb_1;
237     else 236     else
238     { 237     {
239         goto branch_no_1; 238         goto branch_no_1;
240     } 239     }
241     branch_yes_1:; 240     branch_yes_1:;
t 242     { t
243     tmp_result = var_local_value != NULL;
244     if ( tmp_result == true )
245     {
246         Py_DECREF( var_local_value );
247         var_local_value = NULL;
248     }
249  
250     if ( tmp_result == false )
251     {
252  
253         exception_type = PyExc_UnboundLocalError;
254         Py_INCREF( exception_type );
255         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "local_value" );
256         exception_tb = NULL;
257         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
258         CHAIN_EXCEPTION( exception_value );
259  
260         exception_lineno = 37;
261         type_description_1 = "oo";
262         goto frame_exception_exit_1;
263     }
264  
265     }
266     { 241     {
267     PyObject *tmp_assign_source_3; 242     PyObject *tmp_assign_source_3;
268     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 243     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
269 244
270     if (unlikely( tmp_assign_source_3 == NULL )) 245     if (unlikely( tmp_assign_source_3 == NULL ))