Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 002000002000004000004000006000006000008000008000001000000100000012000001200000140000014000001600000160000018000001800000200000020000002200000220000024000002400000260000026000002800000280000030000003000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)316651689.78846153846155257.0CPython 2.71899990244.59615384615387355.8398794180685Nuitka (master)1900041399.4038461538462355.83589937040244Nuitka (develop)1900017554.2115384615385355.83777233400997Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)420383289.78846153846155257.0CPython 3.52353739244.59615384615387365.75468935705106Nuitka (master)2350648399.4038461538462365.9363887336784Nuitka (develop)2354041554.2115384615385365.73693678126926Nuitka (factory)Construct GlobalVariableAccessTicks

Source Code with Construct

module_value1 = 1000
module_value2 = 2000

def calledRepeatedly():
    module_value1
# construct_begin
    return module_value2
# construct_alternative



import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000
module_value2 = 2000

def calledRepeatedly():
    module_value1
# construct_begin

# construct_alternative
    return None
# construct_end

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
22 module_value2 = 2000 22 module_value2 = 2000
23 23
24 def calledRepeatedly(): 24 def calledRepeatedly():
25     module_value1 25     module_value1
26 # construct_begin 26 # construct_begin
n 27     return module_value2 n 27  
28 # construct_alternative 28 # construct_alternative
t 29   t 29     return None
30   30 # construct_end
31 31
32 import itertools 32 import itertools
33 for x in itertools.repeat(None, 50000): 33 for x in itertools.repeat(None, 50000):
34     calledRepeatedly() 34     calledRepeatedly()
35 35

Context Diff of Generated Code


Construct
Baseline
58 static bool constants_created = false; 58 static bool constants_created = false;
59 59
60 /* Function to create module private constants. */ 60 /* Function to create module private constants. */
61 static void createModuleConstants( void ) 61 static void createModuleConstants( void )
62 { 62 {
n 63     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 108 ], 9, 1 ); n 63     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 73 ], 9, 1 );
64     const_str_digest_aff51d481e7337ea9fd2fd65a704b9b8 = UNSTREAM_STRING_ASCII( &constant_bin[ 117 ], 45, 0 ); 64     const_str_digest_aff51d481e7337ea9fd2fd65a704b9b8 = UNSTREAM_STRING_ASCII( &constant_bin[ 82 ], 45, 0 );
65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
66     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul); 66     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul);
n 67     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII( &constant_bin[ 41 ], 13, 1 ); n 67     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII( &constant_bin[ 127 ], 13, 1 );
68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 162 ], 3, 0 ); n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 140 ], 3, 0 );
70     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352); 70     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352);
71     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul); 71     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul);
72     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 13, 1 ); 72     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 13, 1 );
n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 76 ], 16, 1 ); n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 41 ], 16, 1 );
74     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 165 ], 8, 0 ); 74     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 143 ], 8, 0 );
75     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 173 ], 4, 1 ); 75     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 151 ], 4, 1 );
76     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 177 ], 1, 1 ); 76     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 155 ], 1, 1 );
77     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 178 ], 6, 1 ); 77     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 156 ], 6, 1 );
78     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 78     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
79     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF(Py_None); 79     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF(Py_None);
80     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF(const_int_pos_50000); 80     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF(const_int_pos_50000);
81 81
82     constants_created = true; 82     constants_created = true;
123     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 123     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
124     PyObject *exception_type = NULL; 124     PyObject *exception_type = NULL;
125     PyObject *exception_value = NULL; 125     PyObject *exception_value = NULL;
126     PyTracebackObject *exception_tb = NULL; 126     PyTracebackObject *exception_tb = NULL;
127     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 127     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 128     static struct Nuitka_FrameObject *cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd = NULL;
128     PyObject *tmp_return_value = NULL; 129     PyObject *tmp_return_value = NULL;
n 129     static struct Nuitka_FrameObject *cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd = NULL; n
130 130
131     // Actual function body. 131     // Actual function body.
132     MAKE_OR_REUSE_FRAME(cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd, codeobj_f8b70bbf8c13dbfada5f17ac872dcdcd, module___main__, 0); 132     MAKE_OR_REUSE_FRAME(cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd, codeobj_f8b70bbf8c13dbfada5f17ac872dcdcd, module___main__, 0);
133     frame_f8b70bbf8c13dbfada5f17ac872dcdcd = cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd; 133     frame_f8b70bbf8c13dbfada5f17ac872dcdcd = cache_frame_f8b70bbf8c13dbfada5f17ac872dcdcd;
134 134
161 161
162             goto frame_exception_exit_1; 162             goto frame_exception_exit_1;
163         } 163         }
164 164
165     } 165     }
n 166     { n
167         PyObject *tmp_mvar_value_2;
168         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2);
169  
170         if (unlikely( tmp_mvar_value_2 == NULL )) {
171             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2);
172         }
173  
174         if ( tmp_mvar_value_2 == NULL )
175         {
176  
177             exception_type = PyExc_NameError;
178             Py_INCREF(exception_type);
179             exception_value = UNSTREAM_STRING( &constant_bin[ 35 ], 35, 0 );
180             exception_tb = NULL;
181             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
182             CHAIN_EXCEPTION( exception_value );
183  
184             exception_lineno = 27;
185  
186             goto frame_exception_exit_1;
187         }
188  
189         tmp_return_value = tmp_mvar_value_2;
190         Py_INCREF(tmp_return_value);
191         goto frame_return_exit_1;
192     }
193 166
194 #if 0 167 #if 0
195     RESTORE_FRAME_EXCEPTION(frame_f8b70bbf8c13dbfada5f17ac872dcdcd); 168     RESTORE_FRAME_EXCEPTION(frame_f8b70bbf8c13dbfada5f17ac872dcdcd);
196 #endif 169 #endif
197 170
198     // Put the previous frame back on top. 171     // Put the previous frame back on top.
199     popFrameStack(); 172     popFrameStack();
200 173
201     goto frame_no_exception_1; 174     goto frame_no_exception_1;
n 202   n
203     frame_return_exit_1:;
204 #if 0
205     RESTORE_FRAME_EXCEPTION(frame_f8b70bbf8c13dbfada5f17ac872dcdcd);
206 #endif
207  
208     // Put the previous frame back on top.
209     popFrameStack();
210  
211     goto function_return_exit;
212 175
213     frame_exception_exit_1:; 176     frame_exception_exit_1:;
214 177
215 #if 0 178 #if 0
216     RESTORE_FRAME_EXCEPTION(frame_f8b70bbf8c13dbfada5f17ac872dcdcd); 179     RESTORE_FRAME_EXCEPTION(frame_f8b70bbf8c13dbfada5f17ac872dcdcd);
243 206
244     // Return the error. 207     // Return the error.
245     goto function_exception_exit; 208     goto function_exception_exit;
246 209
247     frame_no_exception_1:; 210     frame_no_exception_1:;
n n 211     tmp_return_value = Py_None;
212     Py_INCREF(tmp_return_value);
213     goto function_return_exit;
248 214
249     // Return statement must have exited already. 215     // Return statement must have exited already.
250     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 216     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
251     return NULL; 217     return NULL;
252 218
728         if ( tmp_mvar_value_2 == NULL ) 694         if ( tmp_mvar_value_2 == NULL )
729         { 695         {
730 696
731             exception_type = PyExc_NameError; 697             exception_type = PyExc_NameError;
732             Py_INCREF(exception_type); 698             Py_INCREF(exception_type);
t 733             exception_value = UNSTREAM_STRING( &constant_bin[ 70 ], 38, 0 ); t 699             exception_value = UNSTREAM_STRING( &constant_bin[ 35 ], 38, 0 );
734             exception_tb = NULL; 700             exception_tb = NULL;
735             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 701             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
736             CHAIN_EXCEPTION( exception_value ); 702             CHAIN_EXCEPTION( exception_value );
737 703
738             exception_lineno = 34; 704             exception_lineno = 34;