Construct LocalVariableDeletion

Performance Diagrams

Construct LocalVariableDeletion 00100001000020000200003000030000400004000050000500006000060000700007000080000800009000090000100000100000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)947775.0480.69766467858085CPython 2.7508200.0502.86011377778874Nuitka (historic)100000325.0257.0148260335149Nuitka (master)100006450.0257.0Nuitka (develop)99982575.0257.05930413405963Nuitka (factory)Construct LocalVariableDeletionTicks Construct LocalVariableDeletion 002000200040004000600060008000800010000100001200012000140001400016000160001800018000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)1312075.69230769230768333.1968414052077CPython 3.50201.8461538461538504.11538461538464Nuitka (historic)18969328.00000000000006257.0Nuitka (master)2110454.15384615384613476.62772255947965Nuitka (develop)10151580.3076923076924371.8749782033034Nuitka (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
60 60
61 static bool constants_created = false; 61 static bool constants_created = false;
62 62
63 static void createModuleConstants( void ) 63 static void createModuleConstants( void )
64 { 64 {
n 65     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 57 ], 11, 1 ); n 65     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 );
66     const_str_plain_another_local_value = UNSTREAM_STRING( &constant_bin[ 68 ], 19, 1 ); 66     const_str_plain_another_local_value = UNSTREAM_STRING( &constant_bin[ 11 ], 19, 1 );
67     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 67     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
68     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 68     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
n 69     const_str_plain_local_value = UNSTREAM_STRING( &constant_bin[ 16 ], 11, 1 ); n 69     const_str_plain_local_value = UNSTREAM_STRING( &constant_bin[ 19 ], 11, 1 );
70     const_str_plain_module_value2 = UNSTREAM_STRING( &constant_bin[ 87 ], 13, 1 ); 70     const_str_plain_module_value2 = UNSTREAM_STRING( &constant_bin[ 30 ], 13, 1 );
71     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 71     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 72     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 100 ], 3, 0 ); n 72     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 43 ], 3, 0 );
73     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 73     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
74     const_int_pos_1000 = PyLong_FromUnsignedLong( 1000ul ); 74     const_int_pos_1000 = PyLong_FromUnsignedLong( 1000ul );
n 75     const_str_digest_698aeb1cd69c8d88d32e9f8b82492e6a = UNSTREAM_STRING( &constant_bin[ 103 ], 79, 0 ); n 75     const_str_digest_698aeb1cd69c8d88d32e9f8b82492e6a = UNSTREAM_STRING( &constant_bin[ 46 ], 79, 0 );
76     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 182 ], 13, 1 ); 76     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 125 ], 13, 1 );
77     const_str_plain_module_value3 = UNSTREAM_STRING( &constant_bin[ 195 ], 13, 1 ); 77     const_str_plain_module_value3 = UNSTREAM_STRING( &constant_bin[ 138 ], 13, 1 );
78     const_tuple_str_plain_local_value_str_plain_another_local_value_tuple = PyTuple_New( 2 ); 78     const_tuple_str_plain_local_value_str_plain_another_local_value_tuple = PyTuple_New( 2 );
79     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 ); 79     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, 1, const_str_plain_another_local_value ); Py_INCREF( const_str_plain_another_local_value ); 80     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 81     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 208 ], 16, 1 ); n 81     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 151 ], 16, 1 );
82     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 224 ], 8, 0 ); 82     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 167 ], 8, 0 );
83     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 128 ], 1, 1 ); 83     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 71 ], 1, 1 );
84 84
85     constants_created = true; 85     constants_created = true;
86 } 86 }
87 87
88 #ifndef __NUITKA_NO_ASSERT__ 88 #ifndef __NUITKA_NO_ASSERT__
137     PyObject *tmp_assign_source_4; 137     PyObject *tmp_assign_source_4;
138     PyObject *tmp_assign_source_5; 138     PyObject *tmp_assign_source_5;
139     PyObject *tmp_compare_left_1; 139     PyObject *tmp_compare_left_1;
140     PyObject *tmp_compare_right_1; 140     PyObject *tmp_compare_right_1;
141     bool tmp_is_1; 141     bool tmp_is_1;
n 142     bool tmp_result; n
143     PyObject *tmp_return_value; 142     PyObject *tmp_return_value;
144     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 143     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
145     static struct Nuitka_FrameObject *cache_frame_0a0db944f2456280d1b72953355873cc = NULL; 144     static struct Nuitka_FrameObject *cache_frame_0a0db944f2456280d1b72953355873cc = NULL;
146 145
147     struct Nuitka_FrameObject *frame_0a0db944f2456280d1b72953355873cc; 146     struct Nuitka_FrameObject *frame_0a0db944f2456280d1b72953355873cc;
244     else 243     else
245     { 244     {
246         goto branch_no_1; 245         goto branch_no_1;
247     } 246     }
248     branch_yes_1:; 247     branch_yes_1:;
t 249     tmp_result = var_local_value != NULL; t
250     if ( tmp_result == true )
251     {
252         Py_DECREF( var_local_value );
253         var_local_value = NULL;
254     }
255  
256     if ( tmp_result == false )
257     {
258  
259         exception_type = PyExc_UnboundLocalError;
260         Py_INCREF( exception_type );
261         exception_value = UNSTREAM_STRING( &constant_bin[ 0 ], 57, 0 );
262         exception_tb = NULL;
263         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
264         CHAIN_EXCEPTION( exception_value );
265  
266         exception_lineno = 37;
267         type_description = "oo";
268         goto frame_exception_exit_1;
269     }
270  
271     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 ); 248     tmp_assign_source_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
272 249
273     if (unlikely( tmp_assign_source_3 == NULL )) 250     if (unlikely( tmp_assign_source_3 == NULL ))
274     { 251     {
275         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 ); 252         tmp_assign_source_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );