Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)145346589.78846153846155414.3292442212215CPython 3.104000323244.59615384615387257.0Nuitka (main)3999983399.4038461538462257.021003111691Nuitka (develop)4000143554.2115384615385257.0111192944247Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0040000040000080000080000012000001200000160000016000002000000200000024000002400000280000028000003200000320000036000003600000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)155252289.78846153846155405.74447118392465CPython 3.83899871244.59615384615387257.011721971724Nuitka (main)3900011399.4038461538462257.00285129041936Nuitka (develop)3900056554.2115384615385257.0Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)271430089.78846153846155257.0CPython 2.71950008244.59615384615387326.58269592103363Nuitka (main)1950004399.4038461538462326.58306008915747Nuitka (develop)1950004554.2115384615385326.58306008915747Nuitka (factory)Construct GlobalVariableAccessTicks

Source Code with Construct

    calledRepeatedly()

print("OK.")

#     Python test originally created or extracted from other peoples work. The
#     parts from me are licensed as below. It is at least Free Software where
#     it's copied from other people. In these cases, that will normally be
#     indicated.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

Source Code without Construct

    calledRepeatedly()

print("OK.")

#     Python test originally created or extracted from other peoples work. The
#     parts from me are licensed as below. It is at least Free Software where
#     it's copied from other people. In these cases, that will normally be
#     indicated.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

Context Diff of Source Code


Construct
Baseline
8 8
9 9
10 def calledRepeatedly(): 10 def calledRepeatedly():
11     module_value1 11     module_value1
12     # construct_begin 12     # construct_begin
n 13     return module_value2 n 13  
14     # construct_alternative 14     # construct_alternative
t 15   t 15     return None
16   16     # construct_end
17 17
18 18
19 for x in itertools.repeat(None, 50000): 19 for x in itertools.repeat(None, 50000):
20     calledRepeatedly() 20     calledRepeatedly()
21 21

Context Diff of Generated Code


Construct
Baseline
82 static PyCodeObject *codeobj_1ab5342203c2304ea698b1fdc92171e0; 82 static PyCodeObject *codeobj_1ab5342203c2304ea698b1fdc92171e0;
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_2f3daadac180f77916cac3f9fc559efe = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[13], NULL, NULL, 0, 0, 0); 88     codeobj_2f3daadac180f77916cac3f9fc559efe = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[13], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_2f3daadac180f77916cac3f9fc559efe; 89     codeobj_main = codeobj_2f3daadac180f77916cac3f9fc559efe;
90     codeobj_1ab5342203c2304ea698b1fdc92171e0 = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[8], mod_consts[8], NULL, NULL, 0, 0, 0); 90     codeobj_1ab5342203c2304ea698b1fdc92171e0 = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[8], mod_consts[8], NULL, NULL, 0, 0, 0);
91 } 91 }
92 92
107     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 107     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
108     PyObject *exception_type = NULL; 108     PyObject *exception_type = NULL;
109     PyObject *exception_value = NULL; 109     PyObject *exception_value = NULL;
110     PyTracebackObject *exception_tb = NULL; 110     PyTracebackObject *exception_tb = NULL;
111     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 111     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 112     static struct Nuitka_FrameObject *cache_frame_1ab5342203c2304ea698b1fdc92171e0 = NULL;
112     PyObject *tmp_return_value = NULL; 113     PyObject *tmp_return_value = NULL;
n 113     static struct Nuitka_FrameObject *cache_frame_1ab5342203c2304ea698b1fdc92171e0 = NULL; n
114 114
115     // Actual function body. 115     // Actual function body.
116     if (isFrameUnusable(cache_frame_1ab5342203c2304ea698b1fdc92171e0)) { 116     if (isFrameUnusable(cache_frame_1ab5342203c2304ea698b1fdc92171e0)) {
117         Py_XDECREF(cache_frame_1ab5342203c2304ea698b1fdc92171e0); 117         Py_XDECREF(cache_frame_1ab5342203c2304ea698b1fdc92171e0);
118 118
157             exception_lineno = 11; 157             exception_lineno = 11;
158 158
159             goto frame_exception_exit_1; 159             goto frame_exception_exit_1;
160         } 160         }
161     } 161     }
n 162     tmp_return_value = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[1]); n
163  
164     if (unlikely(tmp_return_value == NULL)) {
165         tmp_return_value = GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION(tstate, mod_consts[1]);
166     }
167  
168     if (tmp_return_value == NULL) {
169         assert(HAS_ERROR_OCCURRED(tstate));
170  
171         FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
172  
173  
174         exception_lineno = 13;
175  
176         goto frame_exception_exit_1;
177     }
178     Py_INCREF(tmp_return_value);
179     goto frame_return_exit_1;
180 162
181 163
182     // Put the previous frame back on top. 164     // Put the previous frame back on top.
183     popFrameStack(tstate); 165     popFrameStack(tstate);
184 166
185     goto frame_no_exception_1; 167     goto frame_no_exception_1;
n 186     frame_return_exit_1: n
187  
188     // Put the previous frame back on top.
189     popFrameStack(tstate);
190  
191     goto function_return_exit;
192     frame_exception_exit_1: 168     frame_exception_exit_1:
193 169
194 170
195     if (exception_tb == NULL) { 171     if (exception_tb == NULL) {
196         exception_tb = MAKE_TRACEBACK(frame_1ab5342203c2304ea698b1fdc92171e0, exception_lineno); 172         exception_tb = MAKE_TRACEBACK(frame_1ab5342203c2304ea698b1fdc92171e0, exception_lineno);
221     popFrameStack(tstate); 197     popFrameStack(tstate);
222 198
223     // Return the error. 199     // Return the error.
224     goto function_exception_exit; 200     goto function_exception_exit;
225     frame_no_exception_1:; 201     frame_no_exception_1:;
n n 202     tmp_return_value = Py_None;
203     Py_INCREF(tmp_return_value);
204     goto function_return_exit;
226 205
227     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 206     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
228     return NULL; 207     return NULL;
229 208
230 function_exception_exit: 209 function_exception_exit:
638 617
639     // Module code. 618     // Module code.
640     { 619     {
641         PyObject *tmp_assign_source_1; 620         PyObject *tmp_assign_source_1;
642         tmp_assign_source_1 = Py_None; 621         tmp_assign_source_1 = Py_None;
n 643         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 622         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
644     } 623     }
645     { 624     {
646         PyObject *tmp_assign_source_2; 625         PyObject *tmp_assign_source_2;
n 647         tmp_assign_source_2 = mod_consts[3]; n 626         tmp_assign_source_2 = mod_consts[2];
648         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 627         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
649     } 628     }
650     frame_2f3daadac180f77916cac3f9fc559efe = MAKE_MODULE_FRAME(codeobj_2f3daadac180f77916cac3f9fc559efe, module___main__); 629     frame_2f3daadac180f77916cac3f9fc559efe = MAKE_MODULE_FRAME(codeobj_2f3daadac180f77916cac3f9fc559efe, module___main__);
651 630
652     // Push the new frame as the currently active one, and we should be exclusively 631     // Push the new frame as the currently active one, and we should be exclusively
653     // owning it. 632     // owning it.
659         PyObject *tmp_assign_source_3; 638         PyObject *tmp_assign_source_3;
660         PyObject *tmp_name_value_1; 639         PyObject *tmp_name_value_1;
661         PyObject *tmp_globals_arg_value_1; 640         PyObject *tmp_globals_arg_value_1;
662         PyObject *tmp_locals_arg_value_1; 641         PyObject *tmp_locals_arg_value_1;
663         PyObject *tmp_fromlist_value_1; 642         PyObject *tmp_fromlist_value_1;
n 664         tmp_name_value_1 = mod_consts[5]; n 643         tmp_name_value_1 = mod_consts[4];
665         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 644         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
666         tmp_locals_arg_value_1 = Py_None; 645         tmp_locals_arg_value_1 = Py_None;
667         tmp_fromlist_value_1 = Py_None; 646         tmp_fromlist_value_1 = Py_None;
668         frame_2f3daadac180f77916cac3f9fc559efe->m_frame.f_lineno = 4; 647         frame_2f3daadac180f77916cac3f9fc559efe->m_frame.f_lineno = 4;
669         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); 648         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1);
675 654
676             exception_lineno = 4; 655             exception_lineno = 4;
677 656
678             goto frame_exception_exit_1; 657             goto frame_exception_exit_1;
679         } 658         }
n 680         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 659         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
681     } 660     }
682     { 661     {
683         PyObject *tmp_assign_source_4; 662         PyObject *tmp_assign_source_4;
n 684         tmp_assign_source_4 = mod_consts[6]; n 663         tmp_assign_source_4 = mod_consts[5];
685         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 664         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
686     } 665     }
687     { 666     {
688         PyObject *tmp_assign_source_5; 667         PyObject *tmp_assign_source_5;
n 689         tmp_assign_source_5 = mod_consts[7]; n 668         tmp_assign_source_5 = mod_consts[6];
690         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_5); 669         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5);
691     } 670     }
692     { 671     {
693         PyObject *tmp_assign_source_6; 672         PyObject *tmp_assign_source_6;
694 673
695 674
699     } 678     }
700     { 679     {
701         PyObject *tmp_assign_source_7; 680         PyObject *tmp_assign_source_7;
702         PyObject *tmp_iter_arg_1; 681         PyObject *tmp_iter_arg_1;
703         PyObject *tmp_called_instance_1; 682         PyObject *tmp_called_instance_1;
n 704         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]); n 683         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]);
705 684
706         if (unlikely(tmp_called_instance_1 == NULL)) { 685         if (unlikely(tmp_called_instance_1 == NULL)) {
t 707             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]); t 686             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]);
708         } 687         }
709 688
710         assert(!(tmp_called_instance_1 == NULL)); 689         assert(!(tmp_called_instance_1 == NULL));
711         frame_2f3daadac180f77916cac3f9fc559efe->m_frame.f_lineno = 19; 690         frame_2f3daadac180f77916cac3f9fc559efe->m_frame.f_lineno = 19;
712         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 691         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(