Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)266296889.78846153846155257.0CPython 2.71950000244.59615384615387323.16127626710556Nuitka (master)1950000399.4038461538462323.16127626710556Nuitka (develop)1950000554.2115384615385323.16127626710556Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)445373289.78846153846155257.0CPython 3.52595934244.59615384615387360.079948974858Nuitka (master)2602542399.4038461538462359.71330399901785Nuitka (develop)2602839554.2115384615385359.6968249497103Nuitka (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
62     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 13, 1); 62     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 13, 1);
63     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2); 63     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2);
64     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None); 64     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None);
65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
66     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000); 66     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000);
n 67     const_str_digest_a20fc139d51123118d540a7679d0423d = UNSTREAM_STRING_ASCII(&constant_bin[ 108 ], 45, 0); n 67     const_str_digest_a20fc139d51123118d540a7679d0423d = UNSTREAM_STRING_ASCII(&constant_bin[ 73 ], 45, 0);
68     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul); 68     const_int_pos_2000 = PyLong_FromUnsignedLong(2000ul);
n 69     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 76 ], 16, 1); n 69     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 41 ], 16, 1);
70     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 153 ], 9, 1); 70     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 118 ], 9, 1);
71     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 162 ], 8, 0); 71     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 127 ], 8, 0);
72     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 170 ], 1, 1); 72     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 135 ], 1, 1);
73     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 171 ], 3, 0); 73     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 136 ], 3, 0);
74     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII(&constant_bin[ 41 ], 13, 1); 74     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII(&constant_bin[ 139 ], 13, 1);
75     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 174 ], 6, 1); 75     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 152 ], 6, 1);
76     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul); 76     const_int_pos_1000 = PyLong_FromUnsignedLong(1000ul);
77 77
78     constants_created = true; 78     constants_created = true;
79 } 79 }
80 80
117     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 117     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
118     PyObject *exception_type = NULL; 118     PyObject *exception_type = NULL;
119     PyObject *exception_value = NULL; 119     PyObject *exception_value = NULL;
120     PyTracebackObject *exception_tb = NULL; 120     PyTracebackObject *exception_tb = NULL;
121     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 121     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 122     static struct Nuitka_FrameObject *cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d = NULL;
122     PyObject *tmp_return_value = NULL; 123     PyObject *tmp_return_value = NULL;
n 123     static struct Nuitka_FrameObject *cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d = NULL; n
124 124
125     // Actual function body. 125     // Actual function body.
126     if (isFrameUnusable(cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d)) { 126     if (isFrameUnusable(cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d)) {
127         Py_XDECREF(cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d); 127         Py_XDECREF(cache_frame_c70a468c56daeb9f3b4c8fe8a69e121d);
128 128
171 171
172             goto frame_exception_exit_1; 172             goto frame_exception_exit_1;
173         } 173         }
174 174
175     } 175     }
n 176     { n
177         PyObject *tmp_mvar_value_2;
178         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2);
179  
180         if (unlikely(tmp_mvar_value_2 == NULL)) {
181             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2);
182         }
183  
184         if (tmp_mvar_value_2 == NULL) {
185  
186             exception_type = PyExc_NameError;
187             Py_INCREF(exception_type);
188             exception_value = UNSTREAM_STRING(&constant_bin[ 35 ], 35, 0);
189             exception_tb = NULL;
190             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
191             CHAIN_EXCEPTION(exception_value);
192  
193             exception_lineno = 27;
194  
195             goto frame_exception_exit_1;
196         }
197  
198         tmp_return_value = tmp_mvar_value_2;
199         Py_INCREF(tmp_return_value);
200         goto frame_return_exit_1;
201     }
202 176
203 #if 0 177 #if 0
204     RESTORE_FRAME_EXCEPTION(frame_c70a468c56daeb9f3b4c8fe8a69e121d); 178     RESTORE_FRAME_EXCEPTION(frame_c70a468c56daeb9f3b4c8fe8a69e121d);
205 #endif 179 #endif
206 180
207     // Put the previous frame back on top. 181     // Put the previous frame back on top.
208     popFrameStack(); 182     popFrameStack();
209 183
210     goto frame_no_exception_1; 184     goto frame_no_exception_1;
n 211   n
212     frame_return_exit_1:;
213 #if 0
214     RESTORE_FRAME_EXCEPTION(frame_c70a468c56daeb9f3b4c8fe8a69e121d);
215 #endif
216  
217     // Put the previous frame back on top.
218     popFrameStack();
219  
220     goto function_return_exit;
221 185
222     frame_exception_exit_1:; 186     frame_exception_exit_1:;
223 187
224 #if 0 188 #if 0
225     RESTORE_FRAME_EXCEPTION(frame_c70a468c56daeb9f3b4c8fe8a69e121d); 189     RESTORE_FRAME_EXCEPTION(frame_c70a468c56daeb9f3b4c8fe8a69e121d);
256 220
257     // Return the error. 221     // Return the error.
258     goto function_exception_exit; 222     goto function_exception_exit;
259 223
260     frame_no_exception_1:; 224     frame_no_exception_1:;
n n 225     tmp_return_value = Py_None;
226     Py_INCREF(tmp_return_value);
227     goto function_return_exit;
261 228
262     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 229     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
263     return NULL; 230     return NULL;
264 231
265 function_exception_exit: 232 function_exception_exit:
840 807
841         if (tmp_mvar_value_2 == NULL) { 808         if (tmp_mvar_value_2 == NULL) {
842 809
843             exception_type = PyExc_NameError; 810             exception_type = PyExc_NameError;
844             Py_INCREF(exception_type); 811             Py_INCREF(exception_type);
t 845             exception_value = UNSTREAM_STRING(&constant_bin[ 70 ], 38, 0); t 812             exception_value = UNSTREAM_STRING(&constant_bin[ 35 ], 38, 0);
846             exception_tb = NULL; 813             exception_tb = NULL;
847             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb); 814             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
848             CHAIN_EXCEPTION(exception_value); 815             CHAIN_EXCEPTION(exception_value);
849 816
850             exception_lineno = 34; 817             exception_lineno = 34;