Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 002000002000004000004000006000006000008000008000001000000100000012000001200000140000014000001600000160000018000001800000200000020000002200000220000024000002400000260000026000002800000280000030000003000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)306308889.78846153846155257.0CPython 2.71800402244.59615384615387358.86750643091597Nuitka (master)1799988399.4038461538462358.900905983665Nuitka (develop)1799094554.2115384615385358.9730296555432Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0040000040000080000080000012000001200000160000016000002000000200000024000002400000280000028000003200000320000036000003600000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)365348189.78846153846155257.0CPython 3.52251298244.59615384615387351.8413284060199Nuitka (master)2249894399.4038461538462351.93629263328694Nuitka (develop)2248336554.2115384615385352.0416731646845Nuitka (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
124     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 124     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
125     PyObject *exception_type = NULL; 125     PyObject *exception_type = NULL;
126     PyObject *exception_value = NULL; 126     PyObject *exception_value = NULL;
127     PyTracebackObject *exception_tb = NULL; 127     PyTracebackObject *exception_tb = NULL;
128     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 128     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 129     static struct Nuitka_FrameObject *cache_frame_a36c3afd98b8d90346e925546cae715f = NULL;
129     PyObject *tmp_return_value = NULL; 130     PyObject *tmp_return_value = NULL;
n 130     static struct Nuitka_FrameObject *cache_frame_a36c3afd98b8d90346e925546cae715f = NULL; n
131 131
132     // Actual function body. 132     // Actual function body.
133     MAKE_OR_REUSE_FRAME( cache_frame_a36c3afd98b8d90346e925546cae715f, codeobj_a36c3afd98b8d90346e925546cae715f, module___main__, 0 ); 133     MAKE_OR_REUSE_FRAME( cache_frame_a36c3afd98b8d90346e925546cae715f, codeobj_a36c3afd98b8d90346e925546cae715f, module___main__, 0 );
134     frame_a36c3afd98b8d90346e925546cae715f = cache_frame_a36c3afd98b8d90346e925546cae715f; 134     frame_a36c3afd98b8d90346e925546cae715f = cache_frame_a36c3afd98b8d90346e925546cae715f;
135 135
163 163
164             goto frame_exception_exit_1; 164             goto frame_exception_exit_1;
165         } 165         }
166 166
167     } 167     }
n 168     { n
169         PyObject *tmp_mvar_value_2;
170         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 );
171  
172         if (unlikely( tmp_mvar_value_2 == NULL ))
173         {
174             tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
175         }
176  
177         if ( tmp_mvar_value_2 == 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         tmp_return_value = tmp_mvar_value_2;
193         Py_INCREF( tmp_return_value );
194         goto frame_return_exit_1;
195     }
196 168
197 #if 0 169 #if 0
198     RESTORE_FRAME_EXCEPTION( frame_a36c3afd98b8d90346e925546cae715f ); 170     RESTORE_FRAME_EXCEPTION( frame_a36c3afd98b8d90346e925546cae715f );
199 #endif 171 #endif
200 172
201     // Put the previous frame back on top. 173     // Put the previous frame back on top.
202     popFrameStack(); 174     popFrameStack();
203 175
204     goto frame_no_exception_1; 176     goto frame_no_exception_1;
n 205   n
206     frame_return_exit_1:;
207 #if 0
208     RESTORE_FRAME_EXCEPTION( frame_a36c3afd98b8d90346e925546cae715f );
209 #endif
210  
211     // Put the previous frame back on top.
212     popFrameStack();
213  
214     goto function_return_exit;
215 177
216     frame_exception_exit_1:; 178     frame_exception_exit_1:;
217 179
218 #if 0 180 #if 0
219     RESTORE_FRAME_EXCEPTION( frame_a36c3afd98b8d90346e925546cae715f ); 181     RESTORE_FRAME_EXCEPTION( frame_a36c3afd98b8d90346e925546cae715f );
249 211
250     // Return the error. 212     // Return the error.
251     goto function_exception_exit; 213     goto function_exception_exit;
252 214
253     frame_no_exception_1:; 215     frame_no_exception_1:;
t t 216     tmp_return_value = Py_None;
217     Py_INCREF( tmp_return_value );
218     goto function_return_exit;
254 219
255     // Return statement must have exited already. 220     // Return statement must have exited already.
256     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 221     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
257     return NULL; 222     return NULL;
258 223