Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)950990.625480.62141160744915CPython 2.7100018246.875257.0Nuitka (master)99988403.125257.0741212735554Nuitka (develop)99988559.375257.0741212735554Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 001000100020002000300030004000400050005000600060007000700080008000900090001000010000110001100012000120001300013000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1355991.46153846153847257.0CPython 3.5839249.15384615384613488.8244481383356Nuitka (master)773406.8461538461538490.0273108409402Nuitka (develop)231564.5384615384615499.90536515626866Nuitka (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
146     PyObject *tmp_assign_source_4; 146     PyObject *tmp_assign_source_4;
147     PyObject *tmp_assign_source_5; 147     PyObject *tmp_assign_source_5;
148     PyObject *tmp_compare_left_1; 148     PyObject *tmp_compare_left_1;
149     PyObject *tmp_compare_right_1; 149     PyObject *tmp_compare_right_1;
150     bool tmp_is_1; 150     bool tmp_is_1;
n 151     bool tmp_result; n
152     PyObject *tmp_return_value; 151     PyObject *tmp_return_value;
153     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 152     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
154     static struct Nuitka_FrameObject *cache_frame_04a1afb38a1f3ded7904d6ef372c6360 = NULL; 153     static struct Nuitka_FrameObject *cache_frame_04a1afb38a1f3ded7904d6ef372c6360 = NULL;
155 154
156     struct Nuitka_FrameObject *frame_04a1afb38a1f3ded7904d6ef372c6360; 155     struct Nuitka_FrameObject *frame_04a1afb38a1f3ded7904d6ef372c6360;
253     else 252     else
254     { 253     {
255         goto branch_no_1; 254         goto branch_no_1;
256     } 255     }
257     branch_yes_1:; 256     branch_yes_1:;
t 258     tmp_result = var_local_value != NULL; t
259     if ( tmp_result == true )
260     {
261         Py_DECREF( var_local_value );
262         var_local_value = NULL;
263     }
264  
265     if ( tmp_result == false )
266     {
267  
268         exception_type = PyExc_UnboundLocalError;
269         Py_INCREF( exception_type );
270         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "local_value" );
271         exception_tb = NULL;
272         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
273         CHAIN_EXCEPTION( exception_value );
274  
275         exception_lineno = 37;
276         type_description = "oo";
277         goto frame_exception_exit_1;
278     }
279  
280     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 257     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
281 258
282     if (unlikely( tmp_assign_source_3 == NULL )) 259     if (unlikely( tmp_assign_source_3 == NULL ))
283     { 260     {
284         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 ); 261         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );