Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)266303089.78846153846155257.0CPython 2.72050003244.59615384615387313.88572899464725Nuitka (master)1749905399.4038461538462341.73326833603943Nuitka (develop)1749905554.2115384615385341.73326833603943Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0040000040000080000080000012000001200000160000016000002000000200000024000002400000280000028000003200000320000036000003600000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)155030689.78846153846155407.1284106264922CPython 3.83949998244.59615384615387257.0039412731172Nuitka (master)3950061399.4038461538462257.0Nuitka (develop)3950061554.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
82 static PyCodeObject *codeobj_8d6b7a2ec4476956b0a9cf9aa36a1a0a; 82 static PyCodeObject *codeobj_8d6b7a2ec4476956b0a9cf9aa36a1a0a;
83 /* For use in "MainProgram.c". */ 83 /* For use in "MainProgram.c". */
84 PyCodeObject *codeobj_main = NULL; 84 PyCodeObject *codeobj_main = NULL;
85 85
86 static void createModuleCodeObjects(void) { 86 static void createModuleCodeObjects(void) {
n 87     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 87     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
88     codeobj_9cce65e842b20af29e5d7c4165b75b25 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0); 88     codeobj_9cce65e842b20af29e5d7c4165b75b25 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0);
89     codeobj_8d6b7a2ec4476956b0a9cf9aa36a1a0a = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], NULL, NULL, 0, 0, 0); 89     codeobj_8d6b7a2ec4476956b0a9cf9aa36a1a0a = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], NULL, NULL, 0, 0, 0);
90 } 90 }
91 91
92 // The module function declarations. 92 // The module function declarations.
106     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 106     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
107     PyObject *exception_type = NULL; 107     PyObject *exception_type = NULL;
108     PyObject *exception_value = NULL; 108     PyObject *exception_value = NULL;
109     PyTracebackObject *exception_tb = NULL; 109     PyTracebackObject *exception_tb = NULL;
110     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 110     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 111     static struct Nuitka_FrameObject *cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a = NULL;
111     PyObject *tmp_return_value = NULL; 112     PyObject *tmp_return_value = NULL;
n 112     static struct Nuitka_FrameObject *cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a = NULL; n
113 113
114     // Actual function body. 114     // Actual function body.
115     if (isFrameUnusable(cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a)) { 115     if (isFrameUnusable(cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a)) {
116         Py_XDECREF(cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a); 116         Py_XDECREF(cache_frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a);
117 117
156             exception_lineno = 25; 156             exception_lineno = 25;
157 157
158             goto frame_exception_exit_1; 158             goto frame_exception_exit_1;
159         } 159         }
160     } 160     }
n 161     tmp_return_value = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[1]); n
162  
163     if (unlikely(tmp_return_value == NULL)) {
164         tmp_return_value = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[1]);
165     }
166  
167     if (tmp_return_value == NULL) {
168         assert(ERROR_OCCURRED());
169  
170         FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
171  
172  
173         exception_lineno = 27;
174  
175         goto frame_exception_exit_1;
176     }
177     Py_INCREF(tmp_return_value);
178     goto frame_return_exit_1;
179 161
180 #if 0 162 #if 0
181     RESTORE_FRAME_EXCEPTION(frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a); 163     RESTORE_FRAME_EXCEPTION(frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a);
182 #endif 164 #endif
183 165
184     // Put the previous frame back on top. 166     // Put the previous frame back on top.
185     popFrameStack(); 167     popFrameStack();
186 168
187     goto frame_no_exception_1; 169     goto frame_no_exception_1;
n 188   n
189     frame_return_exit_1:;
190 #if 0
191     RESTORE_FRAME_EXCEPTION(frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a);
192 #endif
193  
194     // Put the previous frame back on top.
195     popFrameStack();
196  
197     goto function_return_exit;
198 170
199     frame_exception_exit_1:; 171     frame_exception_exit_1:;
200 172
201 #if 0 173 #if 0
202     RESTORE_FRAME_EXCEPTION(frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a); 174     RESTORE_FRAME_EXCEPTION(frame_8d6b7a2ec4476956b0a9cf9aa36a1a0a);
233 205
234     // Return the error. 206     // Return the error.
235     goto function_exception_exit; 207     goto function_exception_exit;
236 208
237     frame_no_exception_1:; 209     frame_no_exception_1:;
n n 210     tmp_return_value = Py_None;
211     Py_INCREF(tmp_return_value);
212     goto function_return_exit;
238 213
239     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 214     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
240     return NULL; 215     return NULL;
241 216
242 function_exception_exit: 217 function_exception_exit:
639 614
640     // Module code. 615     // Module code.
641     { 616     {
642         PyObject *tmp_assign_source_1; 617         PyObject *tmp_assign_source_1;
643         tmp_assign_source_1 = Py_None; 618         tmp_assign_source_1 = Py_None;
n 644         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 619         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
645     } 620     }
646     { 621     {
647         PyObject *tmp_assign_source_2; 622         PyObject *tmp_assign_source_2;
n 648         tmp_assign_source_2 = mod_consts[3]; n 623         tmp_assign_source_2 = mod_consts[2];
649         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 624         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
650     } 625     }
651     { 626     {
652         PyObject *tmp_assign_source_3; 627         PyObject *tmp_assign_source_3;
653         tmp_assign_source_3 = Py_None; 628         tmp_assign_source_3 = Py_None;
n 654         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 629         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
655     } 630     }
656     { 631     {
657         PyObject *tmp_assign_source_4; 632         PyObject *tmp_assign_source_4;
658         tmp_assign_source_4 = PyDict_New(); 633         tmp_assign_source_4 = PyDict_New();
n 659         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 634         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
660     } 635     }
661     { 636     {
662         PyObject *tmp_assign_source_5; 637         PyObject *tmp_assign_source_5;
n 663         tmp_assign_source_5 = mod_consts[7]; n 638         tmp_assign_source_5 = mod_consts[6];
664         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5); 639         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5);
665     } 640     }
666     { 641     {
667         PyObject *tmp_assign_source_6; 642         PyObject *tmp_assign_source_6;
t 668         tmp_assign_source_6 = mod_consts[8]; t 643         tmp_assign_source_6 = mod_consts[7];
669         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_6); 644         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6);
670     } 645     }
671     { 646     {
672         PyObject *tmp_assign_source_7; 647         PyObject *tmp_assign_source_7;
673 648
674 649