Construct GlobalVariableAccess

Performance Diagrams

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