Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 0020000020000040000040000060000060000080000080000010000001000000120000012000001400000140000016000001600000180000018000002000000200000022000002200000240000024000002600000260000028000002800000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)280677689.78846153846155257.0CPython 2.71750000244.59615384615387350.041128929529Nuitka (master)1750012399.4038461538462350.0400724203472Nuitka (develop)1750000554.2115384615385350.041128929529Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)415429689.78846153846155257.0CPython 3.52154772244.59615384615387375.9402830967491Nuitka (master)2159434399.4038461538462375.6629672956899Nuitka (develop)2156332554.2115384615385375.8474875906032Nuitka (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
165         exception_lineno = 25; 165         exception_lineno = 25;
166 166
167         goto frame_exception_exit_1; 167         goto frame_exception_exit_1;
168     } 168     }
169 169
n 170     tmp_return_value = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 ); n
171  
172     if (unlikely( tmp_return_value == NULL ))
173     {
174         tmp_return_value = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
175     }
176  
177     if ( tmp_return_value == NULL )
178     {
179  
180         exception_type = PyExc_NameError;
181         Py_INCREF( exception_type );
182         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
183         exception_tb = NULL;
184         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
185         CHAIN_EXCEPTION( exception_value );
186  
187         exception_lineno = 27;
188  
189         goto frame_exception_exit_1;
190     }
191  
192     Py_INCREF( tmp_return_value );
193     goto frame_return_exit_1;
194 170
195 #if 0 171 #if 0
196     RESTORE_FRAME_EXCEPTION( frame_fffcb2b98379878bab303f8de64954bf ); 172     RESTORE_FRAME_EXCEPTION( frame_fffcb2b98379878bab303f8de64954bf );
197 #endif 173 #endif
198 174
199     // Put the previous frame back on top. 175     // Put the previous frame back on top.
200     popFrameStack(); 176     popFrameStack();
201 177
202     goto frame_no_exception_1; 178     goto frame_no_exception_1;
203 179
n 204     frame_return_exit_1:; n 180     frame_exception_exit_1:;
181  
205 #if 0 182 #if 0
206     RESTORE_FRAME_EXCEPTION( frame_fffcb2b98379878bab303f8de64954bf ); 183     RESTORE_FRAME_EXCEPTION( frame_fffcb2b98379878bab303f8de64954bf );
207 #endif 184 #endif
208 185
n n 186     if ( exception_tb == NULL )
187     {
188         exception_tb = MAKE_TRACEBACK( frame_fffcb2b98379878bab303f8de64954bf, exception_lineno );
189     }
190     else if ( exception_tb->tb_frame != &frame_fffcb2b98379878bab303f8de64954bf->m_frame )
191     {
192         exception_tb = ADD_TRACEBACK( exception_tb, frame_fffcb2b98379878bab303f8de64954bf, exception_lineno );
193     }
194  
195     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_fffcb2b98379878bab303f8de64954bf, ""  );
196  
197     // Release cached frame.
198     if ( frame_fffcb2b98379878bab303f8de64954bf == cache_frame_fffcb2b98379878bab303f8de64954bf )
199     {
200         Py_DECREF( frame_fffcb2b98379878bab303f8de64954bf );
201     }
202     cache_frame_fffcb2b98379878bab303f8de64954bf = NULL;
203  
204     assertFrameObject( frame_fffcb2b98379878bab303f8de64954bf );
205  
206  
209     // Put the previous frame back on top. 207     // Put the previous frame back on top.
210     popFrameStack(); 208     popFrameStack();
211 209
n 212     goto function_return_exit; n
213  
214     frame_exception_exit_1:;
215  
216 #if 0
217     RESTORE_FRAME_EXCEPTION( frame_fffcb2b98379878bab303f8de64954bf );
218 #endif
219  
220     if ( exception_tb == NULL )
221     {
222         exception_tb = MAKE_TRACEBACK( frame_fffcb2b98379878bab303f8de64954bf, exception_lineno );
223     }
224     else if ( exception_tb->tb_frame != &frame_fffcb2b98379878bab303f8de64954bf->m_frame )
225     {
226         exception_tb = ADD_TRACEBACK( exception_tb, frame_fffcb2b98379878bab303f8de64954bf, exception_lineno );
227     }
228  
229     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_fffcb2b98379878bab303f8de64954bf, ""  );
230  
231     // Release cached frame.
232     if ( frame_fffcb2b98379878bab303f8de64954bf == cache_frame_fffcb2b98379878bab303f8de64954bf )
233     {
234         Py_DECREF( frame_fffcb2b98379878bab303f8de64954bf );
235     }
236     cache_frame_fffcb2b98379878bab303f8de64954bf = NULL;
237  
238     assertFrameObject( frame_fffcb2b98379878bab303f8de64954bf );
239  
240  
241     // Put the previous frame back on top.
242     popFrameStack();
243  
244     // Return the error. 210     // Return the error.
245     goto function_exception_exit; 211     goto function_exception_exit;
246 212
247     frame_no_exception_1:; 213     frame_no_exception_1:;
248 214
t t 215     tmp_return_value = Py_None;
216     Py_INCREF( tmp_return_value );
217     goto function_return_exit;
249 218
250     // Return statement must have exited already. 219     // Return statement must have exited already.
251     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 220     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
252     return NULL; 221     return NULL;
253 222