Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 002000002000004000004000006000006000008000008000001000000100000012000001200000140000014000001600000160000018000001800000200000020000002200000220000024000002400000260000026000002800000280000030000003000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)316249189.78846153846155257.0CPython 2.71799892244.59615384615387363.4727697127165Nuitka (master)1799988399.4038461538462363.46526832317164Nuitka (develop)1800181554.2115384615385363.4501874046075Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 00400000400000800000800000120000012000001600000160000020000002000000240000024000002800000280000032000003200000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)355118589.78846153846155257.0CPython 3.52257076244.59615384615387347.0528255411168Nuitka (master)2250848399.4038461538462347.48621175315157Nuitka (develop)2250926554.2115384615385347.4807839874902Nuitka (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
123     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 123     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
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_85918a0b9ac1bed3950cfc3260d41bcc = NULL;
128     PyObject *tmp_return_value = NULL; 129     PyObject *tmp_return_value = NULL;
n 129     static struct Nuitka_FrameObject *cache_frame_85918a0b9ac1bed3950cfc3260d41bcc = NULL; n
130 130
131     // Actual function code. 131     // Actual function code.
132     MAKE_OR_REUSE_FRAME( cache_frame_85918a0b9ac1bed3950cfc3260d41bcc, codeobj_85918a0b9ac1bed3950cfc3260d41bcc, module___main__, 0 ); 132     MAKE_OR_REUSE_FRAME( cache_frame_85918a0b9ac1bed3950cfc3260d41bcc, codeobj_85918a0b9ac1bed3950cfc3260d41bcc, module___main__, 0 );
133     frame_85918a0b9ac1bed3950cfc3260d41bcc = cache_frame_85918a0b9ac1bed3950cfc3260d41bcc; 133     frame_85918a0b9ac1bed3950cfc3260d41bcc = cache_frame_85918a0b9ac1bed3950cfc3260d41bcc;
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     tmp_return_value = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 );
168  
169     if (unlikely( tmp_return_value == NULL ))
170     {
171         tmp_return_value = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
172     }
173  
174     if ( tmp_return_value == NULL )
175     {
176  
177         exception_type = PyExc_NameError;
178         Py_INCREF( exception_type );
179         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
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     Py_INCREF( tmp_return_value );
190     goto frame_return_exit_1;
191     }
192 166
193 #if 0 167 #if 0
194     RESTORE_FRAME_EXCEPTION( frame_85918a0b9ac1bed3950cfc3260d41bcc ); 168     RESTORE_FRAME_EXCEPTION( frame_85918a0b9ac1bed3950cfc3260d41bcc );
195 #endif 169 #endif
196 170
197     // Put the previous frame back on top. 171     // Put the previous frame back on top.
198     popFrameStack(); 172     popFrameStack();
199 173
200     goto frame_no_exception_1; 174     goto frame_no_exception_1;
n 201   n
202     frame_return_exit_1:;
203 #if 0
204     RESTORE_FRAME_EXCEPTION( frame_85918a0b9ac1bed3950cfc3260d41bcc );
205 #endif
206  
207     // Put the previous frame back on top.
208     popFrameStack();
209  
210     goto function_return_exit;
211 175
212     frame_exception_exit_1:; 176     frame_exception_exit_1:;
213 177
214 #if 0 178 #if 0
215     RESTORE_FRAME_EXCEPTION( frame_85918a0b9ac1bed3950cfc3260d41bcc ); 179     RESTORE_FRAME_EXCEPTION( frame_85918a0b9ac1bed3950cfc3260d41bcc );
246     // Return the error. 210     // Return the error.
247     goto function_exception_exit; 211     goto function_exception_exit;
248 212
249     frame_no_exception_1:; 213     frame_no_exception_1:;
250 214
t t 215     {
216     tmp_return_value = Py_None;
217     Py_INCREF( tmp_return_value );
218     goto function_return_exit;
219     }
251 220
252     // Return statement must have exited already. 221     // Return statement must have exited already.
253     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 222     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
254     return NULL; 223     return NULL;
255 224