Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)947775.0480.89410491840295CPython 2.7508200.0502.870643654525Nuitka (historic)100852325.0257.0Nuitka (master)100006450.0259.072934749778Nuitka (develop)100708575.0257.35283995740906Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)1312075.69230769230768470.5391597818199CPython 3.50201.8461538461538504.11538461538464Nuitka (historic)89966328.00000000000006273.87768313851825Nuitka (master)96561454.15384615384613257.0Nuitka (develop)96263580.3076923076924257.7626307164941Nuitka (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

for x in xrange(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

for x in xrange(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
61 61
62 static bool constants_created = false; 62 static bool constants_created = false;
63 63
64 static void createModuleConstants( void ) 64 static void createModuleConstants( void )
65 { 65 {
n 66     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 57 ], 11, 1 ); n 66     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 );
67     const_str_digest_f064428bf05f54177a9a1d20bd09cf36 = UNSTREAM_STRING( &constant_bin[ 68 ], 79, 0 ); 67     const_str_digest_f064428bf05f54177a9a1d20bd09cf36 = UNSTREAM_STRING( &constant_bin[ 11 ], 79, 0 );
68     const_str_plain_another_local_value = UNSTREAM_STRING( &constant_bin[ 147 ], 19, 1 ); 68     const_str_plain_another_local_value = UNSTREAM_STRING( &constant_bin[ 90 ], 19, 1 );
69     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 69     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
70     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 70     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
n 71     const_str_plain_local_value = UNSTREAM_STRING( &constant_bin[ 16 ], 11, 1 ); n 71     const_str_plain_local_value = UNSTREAM_STRING( &constant_bin[ 98 ], 11, 1 );
72     const_str_plain_module_value2 = UNSTREAM_STRING( &constant_bin[ 166 ], 13, 1 ); 72     const_str_plain_module_value2 = UNSTREAM_STRING( &constant_bin[ 109 ], 13, 1 );
73     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 73     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 74     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 179 ], 3, 0 ); n 74     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 122 ], 3, 0 );
75     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 75     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
76     const_int_pos_1000 = PyLong_FromUnsignedLong( 1000ul ); 76     const_int_pos_1000 = PyLong_FromUnsignedLong( 1000ul );
n 77     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 182 ], 13, 1 ); n 77     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 125 ], 13, 1 );
78     const_str_plain_module_value3 = UNSTREAM_STRING( &constant_bin[ 195 ], 13, 1 ); 78     const_str_plain_module_value3 = UNSTREAM_STRING( &constant_bin[ 138 ], 13, 1 );
79     const_tuple_str_plain_local_value_str_plain_another_local_value_tuple = PyTuple_New( 2 ); 79     const_tuple_str_plain_local_value_str_plain_another_local_value_tuple = PyTuple_New( 2 );
80     PyTuple_SET_ITEM( const_tuple_str_plain_local_value_str_plain_another_local_value_tuple, 0, const_str_plain_local_value ); Py_INCREF( const_str_plain_local_value ); 80     PyTuple_SET_ITEM( const_tuple_str_plain_local_value_str_plain_another_local_value_tuple, 0, const_str_plain_local_value ); Py_INCREF( const_str_plain_local_value );
81     PyTuple_SET_ITEM( const_tuple_str_plain_local_value_str_plain_another_local_value_tuple, 1, const_str_plain_another_local_value ); Py_INCREF( const_str_plain_another_local_value ); 81     PyTuple_SET_ITEM( const_tuple_str_plain_local_value_str_plain_another_local_value_tuple, 1, const_str_plain_another_local_value ); Py_INCREF( const_str_plain_another_local_value );
n 82     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 208 ], 16, 1 ); n 82     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 151 ], 16, 1 );
83     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 224 ], 8, 0 ); 83     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 167 ], 8, 0 );
84     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 93 ], 1, 1 ); 84     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 36 ], 1, 1 );
85 85
86     constants_created = true; 86     constants_created = true;
87 } 87 }
88 88
89 #ifndef __NUITKA_NO_ASSERT__ 89 #ifndef __NUITKA_NO_ASSERT__
139     PyObject *tmp_assign_source_5; 139     PyObject *tmp_assign_source_5;
140     PyObject *tmp_compare_left_1; 140     PyObject *tmp_compare_left_1;
141     PyObject *tmp_compare_right_1; 141     PyObject *tmp_compare_right_1;
142     PyObject *tmp_frame_locals; 142     PyObject *tmp_frame_locals;
143     bool tmp_is_1; 143     bool tmp_is_1;
n 144     bool tmp_result; n
145     PyObject *tmp_return_value; 144     PyObject *tmp_return_value;
146     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 145     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
147     static PyFrameObject *cache_frame_function = NULL; 146     static PyFrameObject *cache_frame_function = NULL;
148 147
149     PyFrameObject *frame_function; 148     PyFrameObject *frame_function;
246     else 245     else
247     { 246     {
248         goto branch_no_1; 247         goto branch_no_1;
249     } 248     }
250     branch_yes_1:; 249     branch_yes_1:;
t 251     tmp_result = var_local_value != NULL; t
252     if ( tmp_result == true )
253     {
254         Py_DECREF( var_local_value );
255         var_local_value = NULL;
256     }
257  
258     if ( tmp_result == false )
259     {
260  
261         exception_type = PyExc_UnboundLocalError;
262         Py_INCREF( exception_type );
263         exception_value = UNSTREAM_STRING( &constant_bin[ 0 ], 57, 0 );
264         exception_tb = NULL;
265         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
266         CHAIN_EXCEPTION( exception_value );
267  
268         exception_lineno = 37;
269         goto frame_exception_exit_1;
270     }
271  
272     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 250     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
273 251
274     if (unlikely( tmp_assign_source_3 == NULL )) 252     if (unlikely( tmp_assign_source_3 == NULL ))
275     { 253     {
276         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 ); 254         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );