Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)995590.625479.5959621709896CPython 2.799670246.875258.6255970681367Nuitka (master)100246403.125257.20689417230835Nuitka (develop)100330559.375257.0Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1188390.625475.8196753573086CPython 3.5103778246.875257.0Nuitka (master)100060403.125265.85327333346186Nuitka (develop)99996559.375266.0056696468942Nuitka (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
132     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 132     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
133     PyObject *exception_type = NULL; 133     PyObject *exception_type = NULL;
134     PyObject *exception_value = NULL; 134     PyObject *exception_value = NULL;
135     PyTracebackObject *exception_tb = NULL; 135     PyTracebackObject *exception_tb = NULL;
136     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 136     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 137     bool tmp_result; n
138     static struct Nuitka_FrameObject *cache_frame_ad3352d1c606797972712642d95f27c8 = NULL; 137     static struct Nuitka_FrameObject *cache_frame_ad3352d1c606797972712642d95f27c8 = NULL;
139     PyObject *tmp_return_value = NULL; 138     PyObject *tmp_return_value = NULL;
140     PyObject *exception_keeper_type_1; 139     PyObject *exception_keeper_type_1;
141     PyObject *exception_keeper_value_1; 140     PyObject *exception_keeper_value_1;
142     PyTracebackObject *exception_keeper_tb_1; 141     PyTracebackObject *exception_keeper_tb_1;
240     else 239     else
241     { 240     {
242         goto branch_no_1; 241         goto branch_no_1;
243     } 242     }
244     branch_yes_1:; 243     branch_yes_1:;
t 245     { t
246     tmp_result = var_local_value != NULL;
247     if ( tmp_result == true )
248     {
249         Py_DECREF( var_local_value );
250         var_local_value = NULL;
251     }
252  
253     if ( tmp_result == false )
254     {
255  
256         exception_type = PyExc_UnboundLocalError;
257         Py_INCREF( exception_type );
258         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "local_value" );
259         exception_tb = NULL;
260         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
261         CHAIN_EXCEPTION( exception_value );
262  
263         exception_lineno = 37;
264         type_description_1 = "oo";
265         goto frame_exception_exit_1;
266     }
267  
268     }
269     { 244     {
270     PyObject *tmp_assign_source_3; 245     PyObject *tmp_assign_source_3;
271     PyObject *tmp_mvar_value_4; 246     PyObject *tmp_mvar_value_4;
272     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 );
273 248