Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 0020000020000040000040000060000060000080000080000010000001000000120000012000001400000140000016000001600000180000018000002000000200000022000002200000240000024000002600000260000028000002800000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)280677689.78846153846155257.0CPython 2.71749919244.59615384615387350.0482603665065Nuitka (master)1749876399.4038461538462350.05204619107474Nuitka (develop)1749325554.2115384615385350.1005575710078Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)415429689.78846153846155257.0CPython 3.52138803244.59615384615387376.8901878644698Nuitka (master)2145249399.4038461538462376.50675207433096Nuitka (develop)2140839554.2115384615385376.7690778320896Nuitka (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
166         exception_lineno = 25; 166         exception_lineno = 25;
167 167
168         goto frame_exception_exit_1; 168         goto frame_exception_exit_1;
169     } 169     }
170 170
n 171     tmp_return_value = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 ); n
172  
173     if (unlikely( tmp_return_value == NULL ))
174     {
175         tmp_return_value = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
176     }
177  
178     if ( tmp_return_value == NULL )
179     {
180  
181         exception_type = PyExc_NameError;
182         Py_INCREF( exception_type );
183         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
184         exception_tb = NULL;
185         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
186         CHAIN_EXCEPTION( exception_value );
187  
188         exception_lineno = 27;
189  
190         goto frame_exception_exit_1;
191     }
192  
193     Py_INCREF( tmp_return_value );
194     goto frame_return_exit_1;
195 171
196 #if 0 172 #if 0
197     RESTORE_FRAME_EXCEPTION( frame_f74d0aea4195780dc31af82f9fc55a36 ); 173     RESTORE_FRAME_EXCEPTION( frame_f74d0aea4195780dc31af82f9fc55a36 );
198 #endif 174 #endif
199 175
200     // Put the previous frame back on top. 176     // Put the previous frame back on top.
201     popFrameStack(); 177     popFrameStack();
202 178
203     goto frame_no_exception_1; 179     goto frame_no_exception_1;
n 204   n
205     frame_return_exit_1:;
206 #if 0
207     RESTORE_FRAME_EXCEPTION( frame_f74d0aea4195780dc31af82f9fc55a36 );
208 #endif
209  
210     // Put the previous frame back on top.
211     popFrameStack();
212  
213     goto function_return_exit;
214 180
215     frame_exception_exit_1:; 181     frame_exception_exit_1:;
216 182
217 #if 0 183 #if 0
218     RESTORE_FRAME_EXCEPTION( frame_f74d0aea4195780dc31af82f9fc55a36 ); 184     RESTORE_FRAME_EXCEPTION( frame_f74d0aea4195780dc31af82f9fc55a36 );
249     // Return the error. 215     // Return the error.
250     goto function_exception_exit; 216     goto function_exception_exit;
251 217
252     frame_no_exception_1:; 218     frame_no_exception_1:;
253 219
t t 220     tmp_return_value = Py_None;
221     Py_INCREF( tmp_return_value );
222     goto function_return_exit;
254 223
255     // Return statement must have exited already. 224     // Return statement must have exited already.
256     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 225     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
257     return NULL; 226     return NULL;
258 227