Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 002000002000004000004000006000006000008000008000001000000100000012000001200000140000014000001600000160000018000001800000200000020000002200000220000024000002400000260000026000002800000280000030000003000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)316651689.78846153846155257.0CPython 2.71899976244.59615384615387355.8409719801729Nuitka (master)1900017399.4038461538462355.83777233400997Nuitka (develop)1899981554.2115384615385355.8405817794213Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)420383289.78846153846155257.0CPython 3.52349969244.59615384615387365.9763026375057Nuitka (master)2354066399.4038461538462365.7354671971814Nuitka (develop)2349728554.2115384615385365.990469428113Nuitka (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
58 static bool constants_created = false; 58 static bool constants_created = false;
59 59
60 /* Function to create module private constants. */ 60 /* Function to create module private constants. */
61 static void createModuleConstants( void ) 61 static void createModuleConstants( void )
62 { 62 {
n 63     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 108 ], 9, 1); n 63     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 73 ], 9, 1);
64     const_str_digest_7a2add6b560ecdf4e31fb9dfaf12c319 = UNSTREAM_STRING_ASCII(&constant_bin[ 117 ], 45, 0); 64     const_str_digest_7a2add6b560ecdf4e31fb9dfaf12c319 = UNSTREAM_STRING_ASCII(&constant_bin[ 82 ], 45, 0);
65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
66     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul); 66     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul);
n 67     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII(&constant_bin[ 41 ], 13, 1); n 67     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII(&constant_bin[ 127 ], 13, 1);
68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New(1); 68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New(1);
n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 162 ], 3, 0); n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 140 ], 3, 0);
70     PyTuple_SET_ITEM(const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352); 70     PyTuple_SET_ITEM(const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352);
71     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul); 71     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul);
72     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 13, 1); 72     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 13, 1);
n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 76 ], 16, 1); n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 41 ], 16, 1);
74     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 165 ], 8, 0); 74     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 143 ], 8, 0);
75     const_str_plain_None = UNSTREAM_STRING_ASCII(&constant_bin[ 173 ], 4, 1); 75     const_str_plain_None = UNSTREAM_STRING_ASCII(&constant_bin[ 151 ], 4, 1);
76     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 177 ], 1, 1); 76     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 155 ], 1, 1);
77     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 178 ], 6, 1); 77     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 156 ], 6, 1);
78     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2); 78     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2);
79     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None); 79     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None);
80     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000); 80     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000);
81 81
82     constants_created = true; 82     constants_created = true;
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_25648caef1e08b7d1adfeee93d92a867 = NULL;
127     PyObject *tmp_return_value = NULL; 128     PyObject *tmp_return_value = NULL;
n 128     static struct Nuitka_FrameObject *cache_frame_25648caef1e08b7d1adfeee93d92a867 = NULL; n
129 129
130     // Actual function body. 130     // Actual function body.
131     MAKE_OR_REUSE_FRAME(cache_frame_25648caef1e08b7d1adfeee93d92a867, codeobj_25648caef1e08b7d1adfeee93d92a867, module___main__, 0); 131     MAKE_OR_REUSE_FRAME(cache_frame_25648caef1e08b7d1adfeee93d92a867, codeobj_25648caef1e08b7d1adfeee93d92a867, module___main__, 0);
132     frame_25648caef1e08b7d1adfeee93d92a867 = cache_frame_25648caef1e08b7d1adfeee93d92a867; 132     frame_25648caef1e08b7d1adfeee93d92a867 = cache_frame_25648caef1e08b7d1adfeee93d92a867;
133 133
159 159
160             goto frame_exception_exit_1; 160             goto frame_exception_exit_1;
161         } 161         }
162 162
163     } 163     }
n 164     { n
165         PyObject *tmp_mvar_value_2;
166         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2);
167  
168         if (unlikely(tmp_mvar_value_2 == NULL)) {
169             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2);
170         }
171  
172         if (tmp_mvar_value_2 == NULL) {
173  
174             exception_type = PyExc_NameError;
175             Py_INCREF(exception_type);
176             exception_value = UNSTREAM_STRING(&constant_bin[ 35 ], 35, 0);
177             exception_tb = NULL;
178             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
179             CHAIN_EXCEPTION(exception_value);
180  
181             exception_lineno = 27;
182  
183             goto frame_exception_exit_1;
184         }
185  
186         tmp_return_value = tmp_mvar_value_2;
187         Py_INCREF(tmp_return_value);
188         goto frame_return_exit_1;
189     }
190 164
191 #if 0 165 #if 0
192     RESTORE_FRAME_EXCEPTION(frame_25648caef1e08b7d1adfeee93d92a867); 166     RESTORE_FRAME_EXCEPTION(frame_25648caef1e08b7d1adfeee93d92a867);
193 #endif 167 #endif
194 168
195     // Put the previous frame back on top. 169     // Put the previous frame back on top.
196     popFrameStack(); 170     popFrameStack();
197 171
198     goto frame_no_exception_1; 172     goto frame_no_exception_1;
n 199   n
200     frame_return_exit_1:;
201 #if 0
202     RESTORE_FRAME_EXCEPTION(frame_25648caef1e08b7d1adfeee93d92a867);
203 #endif
204  
205     // Put the previous frame back on top.
206     popFrameStack();
207  
208     goto function_return_exit;
209 173
210     frame_exception_exit_1:; 174     frame_exception_exit_1:;
211 175
212 #if 0 176 #if 0
213     RESTORE_FRAME_EXCEPTION(frame_25648caef1e08b7d1adfeee93d92a867); 177     RESTORE_FRAME_EXCEPTION(frame_25648caef1e08b7d1adfeee93d92a867);
240 204
241     // Return the error. 205     // Return the error.
242     goto function_exception_exit; 206     goto function_exception_exit;
243 207
244     frame_no_exception_1:; 208     frame_no_exception_1:;
n n 209     tmp_return_value = Py_None;
210     Py_INCREF(tmp_return_value);
211     goto function_return_exit;
245 212
246     // Return statement must have exited already. 213     // Return statement must have exited already.
247     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 214     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
248     return NULL; 215     return NULL;
249 216
721 688
722         if (tmp_mvar_value_2 == NULL) { 689         if (tmp_mvar_value_2 == NULL) {
723 690
724             exception_type = PyExc_NameError; 691             exception_type = PyExc_NameError;
725             Py_INCREF(exception_type); 692             Py_INCREF(exception_type);
t 726             exception_value = UNSTREAM_STRING(&constant_bin[ 70 ], 38, 0); t 693             exception_value = UNSTREAM_STRING(&constant_bin[ 35 ], 38, 0);
727             exception_tb = NULL; 694             exception_tb = NULL;
728             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb); 695             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
729             CHAIN_EXCEPTION(exception_value); 696             CHAIN_EXCEPTION(exception_value);
730 697
731             exception_lineno = 34; 698             exception_lineno = 34;