Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 002000002000004000004000006000006000008000008000001000000100000012000001200000140000014000001600000160000018000001800000200000020000002200000220000024000002400000260000026000002800000280000030000003000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)316249189.78846153846155257.0CPython 2.71799892244.59615384615387363.4727697127165Nuitka (master)1799994399.4038461538462363.4647994863251Nuitka (develop)1799862554.2115384615385363.4751138969492Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 00400000400000800000800000120000012000001600000160000020000002000000240000024000002800000280000032000003200000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)355118589.78846153846155257.0CPython 3.52250526244.59615384615387347.5086186831893Nuitka (master)2243396399.4038461538462348.0047721340255Nuitka (develop)2249790554.2115384615385347.55983452327564Nuitka (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
122     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 122     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
123     PyObject *exception_type = NULL; 123     PyObject *exception_type = NULL;
124     PyObject *exception_value = NULL; 124     PyObject *exception_value = NULL;
125     PyTracebackObject *exception_tb = NULL; 125     PyTracebackObject *exception_tb = NULL;
126     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 126     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 127     static struct Nuitka_FrameObject *cache_frame_bedb0512aafe804199145db456084984 = NULL;
127     PyObject *tmp_return_value = NULL; 128     PyObject *tmp_return_value = NULL;
n 128     static struct Nuitka_FrameObject *cache_frame_bedb0512aafe804199145db456084984 = NULL; n
129 129
130     // Actual function code. 130     // Actual function code.
131     MAKE_OR_REUSE_FRAME( cache_frame_bedb0512aafe804199145db456084984, codeobj_bedb0512aafe804199145db456084984, module___main__, 0 ); 131     MAKE_OR_REUSE_FRAME( cache_frame_bedb0512aafe804199145db456084984, codeobj_bedb0512aafe804199145db456084984, module___main__, 0 );
132     frame_bedb0512aafe804199145db456084984 = cache_frame_bedb0512aafe804199145db456084984; 132     frame_bedb0512aafe804199145db456084984 = cache_frame_bedb0512aafe804199145db456084984;
133 133
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     {
172         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
173     }
174  
175     if ( tmp_mvar_value_2 == NULL )
176     {
177  
178         exception_type = PyExc_NameError;
179         Py_INCREF( exception_type );
180         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
181         exception_tb = NULL;
182         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
183         CHAIN_EXCEPTION( exception_value );
184  
185         exception_lineno = 27;
186  
187         goto frame_exception_exit_1;
188     }
189  
190     tmp_return_value = tmp_mvar_value_2;
191     Py_INCREF( tmp_return_value );
192     goto frame_return_exit_1;
193     }
194 166
195 #if 0 167 #if 0
196     RESTORE_FRAME_EXCEPTION( frame_bedb0512aafe804199145db456084984 ); 168     RESTORE_FRAME_EXCEPTION( frame_bedb0512aafe804199145db456084984 );
197 #endif 169 #endif
198 170
199     // Put the previous frame back on top. 171     // Put the previous frame back on top.
200     popFrameStack(); 172     popFrameStack();
201 173
202     goto frame_no_exception_1; 174     goto frame_no_exception_1;
n 203   n
204     frame_return_exit_1:;
205 #if 0
206     RESTORE_FRAME_EXCEPTION( frame_bedb0512aafe804199145db456084984 );
207 #endif
208  
209     // Put the previous frame back on top.
210     popFrameStack();
211  
212     goto function_return_exit;
213 175
214     frame_exception_exit_1:; 176     frame_exception_exit_1:;
215 177
216 #if 0 178 #if 0
217     RESTORE_FRAME_EXCEPTION( frame_bedb0512aafe804199145db456084984 ); 179     RESTORE_FRAME_EXCEPTION( frame_bedb0512aafe804199145db456084984 );
247 209
248     // Return the error. 210     // Return the error.
249     goto function_exception_exit; 211     goto function_exception_exit;
250 212
251     frame_no_exception_1:; 213     frame_no_exception_1:;
t t 214     {
215     tmp_return_value = Py_None;
216     Py_INCREF( tmp_return_value );
217     goto function_return_exit;
218     }
252 219
253     // Return statement must have exited already. 220     // Return statement must have exited already.
254     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 221     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
255     return NULL; 222     return NULL;
256 223