Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)266303089.78846153846155257.0CPython 2.71749867244.59615384615387341.7367945391297Nuitka (main)1749867399.4038461538462341.7367945391297Nuitka (develop)1749867554.2115384615385341.7367945391297Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0040000040000080000080000012000001200000160000016000002000000200000024000002400000280000028000003200000320000036000003600000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)155030689.78846153846155407.12976103837104CPython 3.83950116244.59615384615387257.0Nuitka (main)3950116399.4038461538462257.0Nuitka (develop)3950116554.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_ef22b9ee91940a796696ef5dbf7f16e7; 82 static PyCodeObject *codeobj_ef22b9ee91940a796696ef5dbf7f16e7;
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_6b53ce31f8be494ba7f0151e077f1d03 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0); 88     codeobj_6b53ce31f8be494ba7f0151e077f1d03 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0);
89     codeobj_ef22b9ee91940a796696ef5dbf7f16e7 = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], NULL, NULL, 0, 0, 0); 89     codeobj_ef22b9ee91940a796696ef5dbf7f16e7 = 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_ef22b9ee91940a796696ef5dbf7f16e7 = NULL;
111     PyObject *tmp_return_value = NULL; 112     PyObject *tmp_return_value = NULL;
n 112     static struct Nuitka_FrameObject *cache_frame_ef22b9ee91940a796696ef5dbf7f16e7 = NULL; n
113 113
114     // Actual function body. 114     // Actual function body.
115     if (isFrameUnusable(cache_frame_ef22b9ee91940a796696ef5dbf7f16e7)) { 115     if (isFrameUnusable(cache_frame_ef22b9ee91940a796696ef5dbf7f16e7)) {
116         Py_XDECREF(cache_frame_ef22b9ee91940a796696ef5dbf7f16e7); 116         Py_XDECREF(cache_frame_ef22b9ee91940a796696ef5dbf7f16e7);
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_ef22b9ee91940a796696ef5dbf7f16e7); 163     RESTORE_FRAME_EXCEPTION(frame_ef22b9ee91940a796696ef5dbf7f16e7);
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_ef22b9ee91940a796696ef5dbf7f16e7);
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_ef22b9ee91940a796696ef5dbf7f16e7); 174     RESTORE_FRAME_EXCEPTION(frame_ef22b9ee91940a796696ef5dbf7f16e7);
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:
644 619
645     // Module code. 620     // Module code.
646     { 621     {
647         PyObject *tmp_assign_source_1; 622         PyObject *tmp_assign_source_1;
648         tmp_assign_source_1 = Py_None; 623         tmp_assign_source_1 = Py_None;
n 649         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 624         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
650     } 625     }
651     { 626     {
652         PyObject *tmp_assign_source_2; 627         PyObject *tmp_assign_source_2;
n 653         tmp_assign_source_2 = mod_consts[3]; n 628         tmp_assign_source_2 = mod_consts[2];
654         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 629         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
655     } 630     }
656     { 631     {
657         PyObject *tmp_assign_source_3; 632         PyObject *tmp_assign_source_3;
658         tmp_assign_source_3 = Py_None; 633         tmp_assign_source_3 = Py_None;
n 659         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 634         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
660     } 635     }
661     { 636     {
662         PyObject *tmp_assign_source_4; 637         PyObject *tmp_assign_source_4;
663         tmp_assign_source_4 = PyDict_New(); 638         tmp_assign_source_4 = PyDict_New();
n 664         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 639         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
665     } 640     }
666     { 641     {
667         PyObject *tmp_assign_source_5; 642         PyObject *tmp_assign_source_5;
n 668         tmp_assign_source_5 = mod_consts[7]; n 643         tmp_assign_source_5 = mod_consts[6];
669         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5); 644         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_5);
670     } 645     }
671     { 646     {
672         PyObject *tmp_assign_source_6; 647         PyObject *tmp_assign_source_6;
t 673         tmp_assign_source_6 = mod_consts[8]; t 648         tmp_assign_source_6 = mod_consts[7];
674         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_6); 649         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6);
675     } 650     }
676     { 651     {
677         PyObject *tmp_assign_source_7; 652         PyObject *tmp_assign_source_7;
678 653
679 654