Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)10298822088.11538461538461257.0CPython 3.1032200515240.03846153846155426.85176505735694Nuitka (main)32050258391.96153846153845427.21229965389773Nuitka (develop)32050043543.8846153846154427.21281553627426Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 0010000000100000002000000020000000300000003000000040000000400000005000000050000000600000006000000070000000700000008000000080000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)8826305588.95192307692307257.0CPython 3.828000409242.31730769230768425.72095515196895Nuitka (main)30699757395.6826923076923418.1634281750161Nuitka (develop)30699984549.0480769230769418.1627926294608Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)11475157988.11538461538461257.0CPython 2.730950908240.03846153846155437.4631816455642Nuitka (main)30949914391.96153846153845437.4653222060205Nuitka (develop)30949914543.8846153846154437.4653222060205Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks

Source Code with Construct

    inst.compiled_method()
    inst.compiled_method()
    inst.compiled_method()

    # construct_alternative




for x in itertools.repeat(None, 50000):
    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

    # construct_alternative
    pass
    # construct_end


for x in itertools.repeat(None, 50000):
    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
15     inst = C() 15     inst = C()
16 16
17     # This is supposed to make a call to a compiled method, which is 17     # This is supposed to make a call to a compiled method, which is
18     # being optimized separately. 18     # being optimized separately.
19     # construct_begin 19     # construct_begin
n 20     inst.compiled_method() n 20  
21     inst.compiled_method() 21  
22     inst.compiled_method() 22  
23 23
24     # construct_alternative 24     # construct_alternative
t 25   t 25     pass
26   26     # construct_end
27 27
28 28
29 for x in itertools.repeat(None, 50000): 29 for x in itertools.repeat(None, 50000):
30     calledRepeatedly() 30     calledRepeatedly()
31 31

Context Diff of Generated Code


Construct
Baseline
83 static PyCodeObject *codeobj_466be53e48aedc464710dd14341ad448; 83 static PyCodeObject *codeobj_466be53e48aedc464710dd14341ad448;
84 /* For use in "MainProgram.c". */ 84 /* For use in "MainProgram.c". */
85 PyCodeObject *codeobj_main = NULL; 85 PyCodeObject *codeobj_main = NULL;
86 86
87 static void createModuleCodeObjects(void) { 87 static void createModuleCodeObjects(void) {
n 88     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 88     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
89     codeobj_bda82c53d5f696a24e6cd4c7d181477e = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[17], mod_consts[17], NULL, NULL, 0, 0, 0); 89     codeobj_bda82c53d5f696a24e6cd4c7d181477e = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[17], mod_consts[17], NULL, NULL, 0, 0, 0);
90     codeobj_main = codeobj_bda82c53d5f696a24e6cd4c7d181477e; 90     codeobj_main = codeobj_bda82c53d5f696a24e6cd4c7d181477e;
91     codeobj_a01aefbe9c0e2e68075ee9cb02fe01e6 = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[11], mod_consts[11], mod_consts[18], NULL, 0, 0, 0); 91     codeobj_a01aefbe9c0e2e68075ee9cb02fe01e6 = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[11], mod_consts[11], mod_consts[18], NULL, 0, 0, 0);
n 92     codeobj_466be53e48aedc464710dd14341ad448 = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[1], mod_consts[19], mod_consts[20], NULL, 1, 0, 0); n 92     codeobj_466be53e48aedc464710dd14341ad448 = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[6], mod_consts[19], mod_consts[20], NULL, 1, 0, 0);
93 } 93 }
94 94
95 // The module function declarations. 95 // The module function declarations.
96 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method(); 96 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method();
97 97
145     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 145     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
146     PyObject *exception_type = NULL; 146     PyObject *exception_type = NULL;
147     PyObject *exception_value = NULL; 147     PyObject *exception_value = NULL;
148     PyTracebackObject *exception_tb = NULL; 148     PyTracebackObject *exception_tb = NULL;
149     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 149     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 150     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; n
151     static struct Nuitka_FrameObject *cache_frame_a01aefbe9c0e2e68075ee9cb02fe01e6 = NULL; 150     static struct Nuitka_FrameObject *cache_frame_a01aefbe9c0e2e68075ee9cb02fe01e6 = NULL;
152     PyObject *tmp_return_value = NULL; 151     PyObject *tmp_return_value = NULL;
153     PyObject *exception_keeper_type_1; 152     PyObject *exception_keeper_type_1;
154     PyObject *exception_keeper_value_1; 153     PyObject *exception_keeper_value_1;
155     PyTracebackObject *exception_keeper_tb_1; 154     PyTracebackObject *exception_keeper_tb_1;
215             type_description_1 = "o"; 214             type_description_1 = "o";
216             goto frame_exception_exit_1; 215             goto frame_exception_exit_1;
217         } 216         }
218         assert(var_inst == NULL); 217         assert(var_inst == NULL);
219         var_inst = tmp_assign_source_1; 218         var_inst = tmp_assign_source_1;
n 220     } n
221     {
222         PyObject *tmp_called_instance_1;
223         PyObject *tmp_call_result_1;
224         CHECK_OBJECT(var_inst);
225         tmp_called_instance_1 = var_inst;
226         frame_a01aefbe9c0e2e68075ee9cb02fe01e6->m_frame.f_lineno = 20;
227         tmp_call_result_1 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_1, mod_consts[1]);
228         if (tmp_call_result_1 == NULL) {
229             assert(HAS_ERROR_OCCURRED(tstate));
230  
231             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
232  
233  
234             exception_lineno = 20;
235             type_description_1 = "o";
236             goto frame_exception_exit_1;
237         }
238         Py_DECREF(tmp_call_result_1);
239     }
240     {
241         PyObject *tmp_called_instance_2;
242         PyObject *tmp_call_result_2;
243         CHECK_OBJECT(var_inst);
244         tmp_called_instance_2 = var_inst;
245         frame_a01aefbe9c0e2e68075ee9cb02fe01e6->m_frame.f_lineno = 21;
246         tmp_call_result_2 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_2, mod_consts[1]);
247         if (tmp_call_result_2 == NULL) {
248             assert(HAS_ERROR_OCCURRED(tstate));
249  
250             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
251  
252  
253             exception_lineno = 21;
254             type_description_1 = "o";
255             goto frame_exception_exit_1;
256         }
257         Py_DECREF(tmp_call_result_2);
258     }
259     {
260         PyObject *tmp_called_instance_3;
261         PyObject *tmp_call_result_3;
262         CHECK_OBJECT(var_inst);
263         tmp_called_instance_3 = var_inst;
264         frame_a01aefbe9c0e2e68075ee9cb02fe01e6->m_frame.f_lineno = 22;
265         tmp_call_result_3 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_3, mod_consts[1]);
266         if (tmp_call_result_3 == NULL) {
267             assert(HAS_ERROR_OCCURRED(tstate));
268  
269             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
270  
271  
272             exception_lineno = 22;
273             type_description_1 = "o";
274             goto frame_exception_exit_1;
275         }
276         Py_DECREF(tmp_call_result_3);
277     } 219     }
278 220
279 221
280     // Put the previous frame back on top. 222     // Put the previous frame back on top.
281     popFrameStack(tstate); 223     popFrameStack(tstate);
336     exception_type = NULL; 278     exception_type = NULL;
337     exception_value = NULL; 279     exception_value = NULL;
338     exception_tb = NULL; 280     exception_tb = NULL;
339     exception_lineno = 0; 281     exception_lineno = 0;
340 282
n 341     Py_XDECREF(var_inst); n
342     var_inst = NULL;
343     // Re-raise. 283     // Re-raise.
344     exception_type = exception_keeper_type_1; 284     exception_type = exception_keeper_type_1;
345     exception_value = exception_keeper_value_1; 285     exception_value = exception_keeper_value_1;
346     exception_tb = exception_keeper_tb_1; 286     exception_tb = exception_keeper_tb_1;
347     exception_lineno = exception_keeper_lineno_1; 287     exception_lineno = exception_keeper_lineno_1;
373 313
374 314
375 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method() { 315 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method() {
376     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 316     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
377         impl___main__$$$function__1_compiled_method, 317         impl___main__$$$function__1_compiled_method,
n 378         mod_consts[1], n 318         mod_consts[6],
379 #if PYTHON_VERSION >= 0x300 319 #if PYTHON_VERSION >= 0x300
380         NULL, 320         NULL,
381 #endif 321 #endif
382         codeobj_466be53e48aedc464710dd14341ad448, 322         codeobj_466be53e48aedc464710dd14341ad448,
383         NULL, 323         NULL,
799 739
800     // Module code. 740     // Module code.
801     { 741     {
802         PyObject *tmp_assign_source_1; 742         PyObject *tmp_assign_source_1;
803         tmp_assign_source_1 = Py_None; 743         tmp_assign_source_1 = Py_None;
n 804         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 744         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
805     } 745     }
806     { 746     {
807         PyObject *tmp_assign_source_2; 747         PyObject *tmp_assign_source_2;
n 808         tmp_assign_source_2 = mod_consts[3]; n 748         tmp_assign_source_2 = mod_consts[2];
809         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 749         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
810     } 750     }
811     { 751     {
812         PyObject *tmp_assign_source_3; 752         PyObject *tmp_assign_source_3;
813         { 753         {
814             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 754             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 815             tmp_assign_source_3 = LOOKUP_ATTRIBUTE(tstate, hard_module, mod_consts[5]); n 755             tmp_assign_source_3 = LOOKUP_ATTRIBUTE(tstate, hard_module, mod_consts[4]);
816         } 756         }
817         assert(!(tmp_assign_source_3 == NULL)); 757         assert(!(tmp_assign_source_3 == NULL));
n 818         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 758         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
819     } 759     }
820     frame_bda82c53d5f696a24e6cd4c7d181477e = MAKE_MODULE_FRAME(codeobj_bda82c53d5f696a24e6cd4c7d181477e, module___main__); 760     frame_bda82c53d5f696a24e6cd4c7d181477e = MAKE_MODULE_FRAME(codeobj_bda82c53d5f696a24e6cd4c7d181477e, module___main__);
821 761
822     // Push the new frame as the currently active one, and we should be exclusively 762     // Push the new frame as the currently active one, and we should be exclusively
823     // owning it. 763     // owning it.
829         PyObject *tmp_assign_source_4; 769         PyObject *tmp_assign_source_4;
830         PyObject *tmp_name_value_1; 770         PyObject *tmp_name_value_1;
831         PyObject *tmp_globals_arg_value_1; 771         PyObject *tmp_globals_arg_value_1;
832         PyObject *tmp_locals_arg_value_1; 772         PyObject *tmp_locals_arg_value_1;
833         PyObject *tmp_fromlist_value_1; 773         PyObject *tmp_fromlist_value_1;
n 834         tmp_name_value_1 = mod_consts[6]; n 774         tmp_name_value_1 = mod_consts[5];
835         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 775         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
836         tmp_locals_arg_value_1 = Py_None; 776         tmp_locals_arg_value_1 = Py_None;
837         tmp_fromlist_value_1 = Py_None; 777         tmp_fromlist_value_1 = Py_None;
838         frame_bda82c53d5f696a24e6cd4c7d181477e->m_frame.f_lineno = 6; 778         frame_bda82c53d5f696a24e6cd4c7d181477e->m_frame.f_lineno = 6;
839         tmp_assign_source_4 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); 779         tmp_assign_source_4 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1);
845 785
846             exception_lineno = 6; 786             exception_lineno = 6;
847 787
848             goto frame_exception_exit_1; 788             goto frame_exception_exit_1;
849         } 789         }
n 850         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 790         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
851     } 791     }
852     { 792     {
853         PyObject *tmp_assign_source_5; 793         PyObject *tmp_assign_source_5;
854         { 794         {
855             PyObject *tmp_assign_source_6; 795             PyObject *tmp_assign_source_6;
869             tmp_assign_source_5 = _PyDict_NewPresized( 2 ); 809             tmp_assign_source_5 = _PyDict_NewPresized( 2 );
870             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1); 810             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1);
871             assert(!(tmp_res != 0)); 811             assert(!(tmp_res != 0));
872             CHECK_OBJECT(tmp_locals___main__$$$class__1_C_9_key_compiled_method); 812             CHECK_OBJECT(tmp_locals___main__$$$class__1_C_9_key_compiled_method);
873             tmp_dict_value_1 = tmp_locals___main__$$$class__1_C_9_key_compiled_method; 813             tmp_dict_value_1 = tmp_locals___main__$$$class__1_C_9_key_compiled_method;
n 874             tmp_dict_key_1 = mod_consts[1]; n 814             tmp_dict_key_1 = mod_consts[6];
875             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1); 815             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1);
876             assert(!(tmp_res != 0)); 816             assert(!(tmp_res != 0));
877             goto try_return_handler_1; 817             goto try_return_handler_1;
878         } 818         }
879         NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); 819         NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
1011     } 951     }
1012     { 952     {
1013         PyObject *tmp_assign_source_11; 953         PyObject *tmp_assign_source_11;
1014         PyObject *tmp_iter_arg_1; 954         PyObject *tmp_iter_arg_1;
1015         PyObject *tmp_called_instance_1; 955         PyObject *tmp_called_instance_1;
n 1016         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]); n 956         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]);
1017 957
1018         if (unlikely(tmp_called_instance_1 == NULL)) { 958         if (unlikely(tmp_called_instance_1 == NULL)) {
t 1019             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[6]); t 959             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]);
1020         } 960         }
1021 961
1022         if (tmp_called_instance_1 == NULL) { 962         if (tmp_called_instance_1 == NULL) {
1023             assert(HAS_ERROR_OCCURRED(tstate)); 963             assert(HAS_ERROR_OCCURRED(tstate));
1024 964