Construct GlobalVariableAccess

Performance Diagrams

Construct GlobalVariableAccess 0010000001000000200000020000003000000300000040000004000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)145346589.78846153846155414.3246203702388CPython 3.103999932244.59615384615387257.01142875224747Nuitka (main)3999845399.4038461538462257.01680335465574Nuitka (develop)4000117554.2115384615385257.0Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 0040000040000080000080000012000001200000160000016000002000000200000024000002400000280000028000003200000320000036000003600000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)155252289.78846153846155405.74580798205307CPython 3.83900109244.59615384615387257.0Nuitka (main)3900105399.4038461538462257.0002534445931Nuitka (develop)3899861554.2115384615385257.0157135647708Nuitka (factory)Construct GlobalVariableAccessTicks Construct GlobalVariableAccess 00200000200000400000400000600000600000800000800000100000010000001200000120000014000001400000160000016000001800000180000020000002000000220000022000002400000240000026000002600000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)271430089.78846153846155257.0CPython 2.71950038244.59615384615387326.579964660105Nuitka (main)1950034399.4038461538462326.58032882822886Nuitka (develop)1950034554.2115384615385326.58032882822886Nuitka (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_e6325e9b799ed7fff87846cc93b361e0; 82 static PyCodeObject *codeobj_e6325e9b799ed7fff87846cc93b361e0;
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_e9fcd3628588793acb249f5aa91328a6 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[13], NULL, NULL, 0, 0, 0); 88     codeobj_e9fcd3628588793acb249f5aa91328a6 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[13], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_e9fcd3628588793acb249f5aa91328a6; 89     codeobj_main = codeobj_e9fcd3628588793acb249f5aa91328a6;
90     codeobj_e6325e9b799ed7fff87846cc93b361e0 = 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_e6325e9b799ed7fff87846cc93b361e0 = 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_e6325e9b799ed7fff87846cc93b361e0 = NULL;
112     PyObject *tmp_return_value = NULL; 113     PyObject *tmp_return_value = NULL;
n 113     static struct Nuitka_FrameObject *cache_frame_e6325e9b799ed7fff87846cc93b361e0 = NULL; n
114 114
115     // Actual function body. 115     // Actual function body.
116     if (isFrameUnusable(cache_frame_e6325e9b799ed7fff87846cc93b361e0)) { 116     if (isFrameUnusable(cache_frame_e6325e9b799ed7fff87846cc93b361e0)) {
117         Py_XDECREF(cache_frame_e6325e9b799ed7fff87846cc93b361e0); 117         Py_XDECREF(cache_frame_e6325e9b799ed7fff87846cc93b361e0);
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_e6325e9b799ed7fff87846cc93b361e0, exception_lineno); 172         exception_tb = MAKE_TRACEBACK(frame_e6325e9b799ed7fff87846cc93b361e0, 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:
630 609
631     // Module code. 610     // Module code.
632     { 611     {
633         PyObject *tmp_assign_source_1; 612         PyObject *tmp_assign_source_1;
634         tmp_assign_source_1 = Py_None; 613         tmp_assign_source_1 = Py_None;
n 635         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 614         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
636     } 615     }
637     { 616     {
638         PyObject *tmp_assign_source_2; 617         PyObject *tmp_assign_source_2;
n 639         tmp_assign_source_2 = mod_consts[3]; n 618         tmp_assign_source_2 = mod_consts[2];
640         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 619         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
641     } 620     }
642     frame_e9fcd3628588793acb249f5aa91328a6 = MAKE_MODULE_FRAME(codeobj_e9fcd3628588793acb249f5aa91328a6, module___main__); 621     frame_e9fcd3628588793acb249f5aa91328a6 = MAKE_MODULE_FRAME(codeobj_e9fcd3628588793acb249f5aa91328a6, module___main__);
643 622
644     // Push the new frame as the currently active one, and we should be exclusively 623     // Push the new frame as the currently active one, and we should be exclusively
645     // owning it. 624     // owning it.
651         PyObject *tmp_assign_source_3; 630         PyObject *tmp_assign_source_3;
652         PyObject *tmp_name_value_1; 631         PyObject *tmp_name_value_1;
653         PyObject *tmp_globals_arg_value_1; 632         PyObject *tmp_globals_arg_value_1;
654         PyObject *tmp_locals_arg_value_1; 633         PyObject *tmp_locals_arg_value_1;
655         PyObject *tmp_fromlist_value_1; 634         PyObject *tmp_fromlist_value_1;
n 656         tmp_name_value_1 = mod_consts[5]; n 635         tmp_name_value_1 = mod_consts[4];
657         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 636         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
658         tmp_locals_arg_value_1 = Py_None; 637         tmp_locals_arg_value_1 = Py_None;
659         tmp_fromlist_value_1 = Py_None; 638         tmp_fromlist_value_1 = Py_None;
660         frame_e9fcd3628588793acb249f5aa91328a6->m_frame.f_lineno = 4; 639         frame_e9fcd3628588793acb249f5aa91328a6->m_frame.f_lineno = 4;
661         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); 640         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);
667 646
668             exception_lineno = 4; 647             exception_lineno = 4;
669 648
670             goto frame_exception_exit_1; 649             goto frame_exception_exit_1;
671         } 650         }
n 672         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 651         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
673     } 652     }
674     { 653     {
675         PyObject *tmp_assign_source_4; 654         PyObject *tmp_assign_source_4;
n 676         tmp_assign_source_4 = mod_consts[6]; n 655         tmp_assign_source_4 = mod_consts[5];
677         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 656         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
678     } 657     }
679     { 658     {
680         PyObject *tmp_assign_source_5; 659         PyObject *tmp_assign_source_5;
n 681         tmp_assign_source_5 = mod_consts[7]; n 660         tmp_assign_source_5 = mod_consts[6];
682         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_5); 661         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5);
683     } 662     }
684     { 663     {
685         PyObject *tmp_assign_source_6; 664         PyObject *tmp_assign_source_6;
686 665
687 666
691     } 670     }
692     { 671     {
693         PyObject *tmp_assign_source_7; 672         PyObject *tmp_assign_source_7;
694         PyObject *tmp_iter_arg_1; 673         PyObject *tmp_iter_arg_1;
695         PyObject *tmp_called_instance_1; 674         PyObject *tmp_called_instance_1;
n 696         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]); n 675         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]);
697 676
698         if (unlikely(tmp_called_instance_1 == NULL)) { 677         if (unlikely(tmp_called_instance_1 == NULL)) {
t 699             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]); t 678             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]);
700         } 679         }
701 680
702         assert(!(tmp_called_instance_1 == NULL)); 681         assert(!(tmp_called_instance_1 == NULL));
703         frame_e9fcd3628588793acb249f5aa91328a6->m_frame.f_lineno = 19; 682         frame_e9fcd3628588793acb249f5aa91328a6->m_frame.f_lineno = 19;
704         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 683         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(