Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)266300989.78846153846155257.00000000000006CPython 2.72050000244.59615384615387313.88450726516226Nuitka (master)2050000399.4038461538462313.88450726516226Nuitka (develop)2050000554.2115384615385313.88450726516226Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)155080089.78846153846155408.3088697581436CPython 3.83750009244.59615384615387272.44444511752056Nuitka (master)4000005399.4038461538462257.0Nuitka (develop)4000005554.2115384615385257.0Nuitka (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
70 static PyCodeObject *codeobj_8a848fc5b3614b46fb5468fb05706da5; 70 static PyCodeObject *codeobj_8a848fc5b3614b46fb5468fb05706da5;
71 /* For use in "MainProgram.c". */ 71 /* For use in "MainProgram.c". */
72 PyCodeObject *codeobj_main = NULL; 72 PyCodeObject *codeobj_main = NULL;
73 73
74 static void createModuleCodeObjects(void) { 74 static void createModuleCodeObjects(void) {
n 75     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 75     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
76     codeobj_d2864f5273fbe8826470913c2b45e529 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0); 76     codeobj_d2864f5273fbe8826470913c2b45e529 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0);
77     codeobj_8a848fc5b3614b46fb5468fb05706da5 = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], NULL, NULL, 0, 0, 0); 77     codeobj_8a848fc5b3614b46fb5468fb05706da5 = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], NULL, NULL, 0, 0, 0);
78 } 78 }
79 79
80 // The module function declarations. 80 // The module function declarations.
94     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 94     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
95     PyObject *exception_type = NULL; 95     PyObject *exception_type = NULL;
96     PyObject *exception_value = NULL; 96     PyObject *exception_value = NULL;
97     PyTracebackObject *exception_tb = NULL; 97     PyTracebackObject *exception_tb = NULL;
98     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 98     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 99     static struct Nuitka_FrameObject *cache_frame_8a848fc5b3614b46fb5468fb05706da5 = NULL;
99     PyObject *tmp_return_value = NULL; 100     PyObject *tmp_return_value = NULL;
n 100     static struct Nuitka_FrameObject *cache_frame_8a848fc5b3614b46fb5468fb05706da5 = NULL; n
101 101
102     // Actual function body. 102     // Actual function body.
103     if (isFrameUnusable(cache_frame_8a848fc5b3614b46fb5468fb05706da5)) { 103     if (isFrameUnusable(cache_frame_8a848fc5b3614b46fb5468fb05706da5)) {
104         Py_XDECREF(cache_frame_8a848fc5b3614b46fb5468fb05706da5); 104         Py_XDECREF(cache_frame_8a848fc5b3614b46fb5468fb05706da5);
105 105
144             exception_lineno = 25; 144             exception_lineno = 25;
145 145
146             goto frame_exception_exit_1; 146             goto frame_exception_exit_1;
147         } 147         }
148     } 148     }
n 149     tmp_return_value = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[1]); n
150  
151     if (unlikely(tmp_return_value == NULL)) {
152         tmp_return_value = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[1]);
153     }
154  
155     if (tmp_return_value == NULL) {
156         assert(ERROR_OCCURRED());
157  
158         FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
159  
160  
161         exception_lineno = 27;
162  
163         goto frame_exception_exit_1;
164     }
165     Py_INCREF(tmp_return_value);
166     goto frame_return_exit_1;
167 149
168 #if 0 150 #if 0
169     RESTORE_FRAME_EXCEPTION(frame_8a848fc5b3614b46fb5468fb05706da5); 151     RESTORE_FRAME_EXCEPTION(frame_8a848fc5b3614b46fb5468fb05706da5);
170 #endif 152 #endif
171 153
172     // Put the previous frame back on top. 154     // Put the previous frame back on top.
173     popFrameStack(); 155     popFrameStack();
174 156
175     goto frame_no_exception_1; 157     goto frame_no_exception_1;
n 176   n
177     frame_return_exit_1:;
178 #if 0
179     RESTORE_FRAME_EXCEPTION(frame_8a848fc5b3614b46fb5468fb05706da5);
180 #endif
181  
182     // Put the previous frame back on top.
183     popFrameStack();
184  
185     goto function_return_exit;
186 158
187     frame_exception_exit_1:; 159     frame_exception_exit_1:;
188 160
189 #if 0 161 #if 0
190     RESTORE_FRAME_EXCEPTION(frame_8a848fc5b3614b46fb5468fb05706da5); 162     RESTORE_FRAME_EXCEPTION(frame_8a848fc5b3614b46fb5468fb05706da5);
221 193
222     // Return the error. 194     // Return the error.
223     goto function_exception_exit; 195     goto function_exception_exit;
224 196
225     frame_no_exception_1:; 197     frame_no_exception_1:;
n n 198     tmp_return_value = Py_None;
199     Py_INCREF(tmp_return_value);
200     goto function_return_exit;
226 201
227     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 202     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
228     return NULL; 203     return NULL;
229 204
230 function_exception_exit: 205 function_exception_exit:
629 604
630     // Module code. 605     // Module code.
631     { 606     {
632         PyObject *tmp_assign_source_1; 607         PyObject *tmp_assign_source_1;
633         tmp_assign_source_1 = Py_None; 608         tmp_assign_source_1 = Py_None;
n 634         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 609         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
635     } 610     }
636     { 611     {
637         PyObject *tmp_assign_source_2; 612         PyObject *tmp_assign_source_2;
n 638         tmp_assign_source_2 = mod_consts[3]; n 613         tmp_assign_source_2 = mod_consts[2];
639         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 614         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
640     } 615     }
641     { 616     {
642         PyObject *tmp_assign_source_3; 617         PyObject *tmp_assign_source_3;
643         tmp_assign_source_3 = Py_None; 618         tmp_assign_source_3 = Py_None;
n 644         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 619         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
645     } 620     }
646     { 621     {
647         PyObject *tmp_assign_source_4; 622         PyObject *tmp_assign_source_4;
648         tmp_assign_source_4 = PyDict_New(); 623         tmp_assign_source_4 = PyDict_New();
n 649         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 624         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
650     } 625     }
651     { 626     {
652         PyObject *tmp_assign_source_5; 627         PyObject *tmp_assign_source_5;
n 653         tmp_assign_source_5 = mod_consts[7]; n 628         tmp_assign_source_5 = mod_consts[6];
654         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5); 629         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5);
655     } 630     }
656     { 631     {
657         PyObject *tmp_assign_source_6; 632         PyObject *tmp_assign_source_6;
t 658         tmp_assign_source_6 = mod_consts[8]; t 633         tmp_assign_source_6 = mod_consts[7];
659         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_6); 634         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6);
660     } 635     }
661     { 636     {
662         PyObject *tmp_assign_source_7; 637         PyObject *tmp_assign_source_7;
663 638
664 639