Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)18083711388.11538461538461257.0CPython 3.1074450423240.03846153846155402.37827651178935Nuitka (main)74450236391.96153846153845402.3785320488091Nuitka (develop)74450250543.8846153846154402.37851291769533Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)17346311188.11538461538461257.0CPython 3.869650145240.03846153846155404.8918536238742Nuitka (main)66949945391.96153846153845408.73855600164063Nuitka (develop)66950249543.8846153846154408.7381229235269Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)19594940788.11538461538461257.0CPython 2.769200078240.03846153846155416.84589933245843Nuitka (main)69199983391.96153846153845416.84601913869767Nuitka (develop)69200017543.8846153846154416.84597626067523Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks

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
21     inst.compiled_method()
22     inst.compiled_method()
23     # construct_alternative
24 20
25 21
t t 22  
23     # construct_alternative
24     pass
25     # construct_end
26 26
27 27
28 for x in itertools.repeat(None, 50000): 28 for x in itertools.repeat(None, 50000):
29     calledRepeatedly() 29     calledRepeatedly()
30 30

Context Diff of Generated Code


Construct
Baseline
83 static PyCodeObject *codeobj_2a4190db62799640d2a9a5706211674a; 83 static PyCodeObject *codeobj_2a4190db62799640d2a9a5706211674a;
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_d3231d56f14a6e1ac59d2ad62fcd7775 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[18], mod_consts[18], NULL, NULL, 0, 0, 0); 89     codeobj_d3231d56f14a6e1ac59d2ad62fcd7775 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[18], mod_consts[18], NULL, NULL, 0, 0, 0);
90     codeobj_main = codeobj_d3231d56f14a6e1ac59d2ad62fcd7775; 90     codeobj_main = codeobj_d3231d56f14a6e1ac59d2ad62fcd7775;
91     codeobj_b7755b74df8c1aeb16820f53562eaff7 = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[12], mod_consts[12], mod_consts[19], NULL, 0, 0, 0); 91     codeobj_b7755b74df8c1aeb16820f53562eaff7 = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[12], mod_consts[12], mod_consts[19], NULL, 0, 0, 0);
n 92     codeobj_2a4190db62799640d2a9a5706211674a = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[1], mod_consts[1], mod_consts[20], NULL, 7, 0, 0); n 92     codeobj_2a4190db62799640d2a9a5706211674a = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE | CO_FUTURE_PRINT_FUNCTION, mod_consts[7], mod_consts[7], mod_consts[20], NULL, 7, 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(PyObject *defaults); 96 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method(PyObject *defaults);
97 97
182     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 182     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
183     PyObject *exception_type = NULL; 183     PyObject *exception_type = NULL;
184     PyObject *exception_value = NULL; 184     PyObject *exception_value = NULL;
185     PyTracebackObject *exception_tb = NULL; 185     PyTracebackObject *exception_tb = NULL;
186     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 186     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 187     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; n
188     static struct Nuitka_FrameObject *cache_frame_b7755b74df8c1aeb16820f53562eaff7 = NULL; 187     static struct Nuitka_FrameObject *cache_frame_b7755b74df8c1aeb16820f53562eaff7 = NULL;
189     PyObject *tmp_return_value = NULL; 188     PyObject *tmp_return_value = NULL;
190     PyObject *exception_keeper_type_1; 189     PyObject *exception_keeper_type_1;
191     PyObject *exception_keeper_value_1; 190     PyObject *exception_keeper_value_1;
192     PyTracebackObject *exception_keeper_tb_1; 191     PyTracebackObject *exception_keeper_tb_1;
252             type_description_1 = "o"; 251             type_description_1 = "o";
253             goto frame_exception_exit_1; 252             goto frame_exception_exit_1;
254         } 253         }
255         assert(var_inst == NULL); 254         assert(var_inst == NULL);
256         var_inst = tmp_assign_source_1; 255         var_inst = tmp_assign_source_1;
n 257     } n
258     {
259         PyObject *tmp_called_instance_1;
260         PyObject *tmp_call_result_1;
261         CHECK_OBJECT(var_inst);
262         tmp_called_instance_1 = var_inst;
263         frame_b7755b74df8c1aeb16820f53562eaff7->m_frame.f_lineno = 20;
264         tmp_call_result_1 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_1, mod_consts[1]);
265         if (tmp_call_result_1 == NULL) {
266             assert(HAS_ERROR_OCCURRED(tstate));
267  
268             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
269  
270  
271             exception_lineno = 20;
272             type_description_1 = "o";
273             goto frame_exception_exit_1;
274         }
275         Py_DECREF(tmp_call_result_1);
276     }
277     {
278         PyObject *tmp_called_instance_2;
279         PyObject *tmp_call_result_2;
280         CHECK_OBJECT(var_inst);
281         tmp_called_instance_2 = var_inst;
282         frame_b7755b74df8c1aeb16820f53562eaff7->m_frame.f_lineno = 21;
283         tmp_call_result_2 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_2, mod_consts[1]);
284         if (tmp_call_result_2 == NULL) {
285             assert(HAS_ERROR_OCCURRED(tstate));
286  
287             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
288  
289  
290             exception_lineno = 21;
291             type_description_1 = "o";
292             goto frame_exception_exit_1;
293         }
294         Py_DECREF(tmp_call_result_2);
295     }
296     {
297         PyObject *tmp_called_instance_3;
298         PyObject *tmp_call_result_3;
299         CHECK_OBJECT(var_inst);
300         tmp_called_instance_3 = var_inst;
301         frame_b7755b74df8c1aeb16820f53562eaff7->m_frame.f_lineno = 22;
302         tmp_call_result_3 = CALL_METHOD_NO_ARGS(tstate, tmp_called_instance_3, mod_consts[1]);
303         if (tmp_call_result_3 == NULL) {
304             assert(HAS_ERROR_OCCURRED(tstate));
305  
306             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
307  
308  
309             exception_lineno = 22;
310             type_description_1 = "o";
311             goto frame_exception_exit_1;
312         }
313         Py_DECREF(tmp_call_result_3);
314     } 256     }
315 257
316 258
317     // Put the previous frame back on top. 259     // Put the previous frame back on top.
318     popFrameStack(tstate); 260     popFrameStack(tstate);
373     exception_type = NULL; 315     exception_type = NULL;
374     exception_value = NULL; 316     exception_value = NULL;
375     exception_tb = NULL; 317     exception_tb = NULL;
376     exception_lineno = 0; 318     exception_lineno = 0;
377 319
n 378     Py_XDECREF(var_inst); n
379     var_inst = NULL;
380     // Re-raise. 320     // Re-raise.
381     exception_type = exception_keeper_type_1; 321     exception_type = exception_keeper_type_1;
382     exception_value = exception_keeper_value_1; 322     exception_value = exception_keeper_value_1;
383     exception_tb = exception_keeper_tb_1; 323     exception_tb = exception_keeper_tb_1;
384     exception_lineno = exception_keeper_lineno_1; 324     exception_lineno = exception_keeper_lineno_1;
410 350
411 351
412 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method(PyObject *defaults) { 352 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_method(PyObject *defaults) {
413     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 353     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
414         impl___main__$$$function__1_compiled_method, 354         impl___main__$$$function__1_compiled_method,
n 415         mod_consts[1], n 355         mod_consts[7],
416 #if PYTHON_VERSION >= 0x300 356 #if PYTHON_VERSION >= 0x300
417         NULL, 357         NULL,
418 #endif 358 #endif
419         codeobj_2a4190db62799640d2a9a5706211674a, 359         codeobj_2a4190db62799640d2a9a5706211674a,
420         defaults, 360         defaults,
833 773
834     // Module code. 774     // Module code.
835     { 775     {
836         PyObject *tmp_assign_source_1; 776         PyObject *tmp_assign_source_1;
837         tmp_assign_source_1 = Py_None; 777         tmp_assign_source_1 = Py_None;
n 838         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 778         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
839     } 779     }
840     { 780     {
841         PyObject *tmp_assign_source_2; 781         PyObject *tmp_assign_source_2;
n 842         tmp_assign_source_2 = mod_consts[3]; n 782         tmp_assign_source_2 = mod_consts[2];
843         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 783         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
844     } 784     }
845     { 785     {
846         PyObject *tmp_assign_source_3; 786         PyObject *tmp_assign_source_3;
847         { 787         {
848             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 788             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 849             tmp_assign_source_3 = LOOKUP_ATTRIBUTE(tstate, hard_module, mod_consts[5]); n 789             tmp_assign_source_3 = LOOKUP_ATTRIBUTE(tstate, hard_module, mod_consts[4]);
850         } 790         }
851         assert(!(tmp_assign_source_3 == NULL)); 791         assert(!(tmp_assign_source_3 == NULL));
n 852         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 792         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
853     } 793     }
854     frame_d3231d56f14a6e1ac59d2ad62fcd7775 = MAKE_MODULE_FRAME(codeobj_d3231d56f14a6e1ac59d2ad62fcd7775, module___main__); 794     frame_d3231d56f14a6e1ac59d2ad62fcd7775 = MAKE_MODULE_FRAME(codeobj_d3231d56f14a6e1ac59d2ad62fcd7775, module___main__);
855 795
856     // Push the new frame as the currently active one, and we should be exclusively 796     // Push the new frame as the currently active one, and we should be exclusively
857     // owning it. 797     // owning it.
863         PyObject *tmp_assign_source_4; 803         PyObject *tmp_assign_source_4;
864         PyObject *tmp_name_value_1; 804         PyObject *tmp_name_value_1;
865         PyObject *tmp_globals_arg_value_1; 805         PyObject *tmp_globals_arg_value_1;
866         PyObject *tmp_locals_arg_value_1; 806         PyObject *tmp_locals_arg_value_1;
867         PyObject *tmp_fromlist_value_1; 807         PyObject *tmp_fromlist_value_1;
n 868         tmp_name_value_1 = mod_consts[6]; n 808         tmp_name_value_1 = mod_consts[5];
869         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 809         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
870         tmp_locals_arg_value_1 = Py_None; 810         tmp_locals_arg_value_1 = Py_None;
871         tmp_fromlist_value_1 = Py_None; 811         tmp_fromlist_value_1 = Py_None;
872         frame_d3231d56f14a6e1ac59d2ad62fcd7775->m_frame.f_lineno = 6; 812         frame_d3231d56f14a6e1ac59d2ad62fcd7775->m_frame.f_lineno = 6;
873         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); 813         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);
879 819
880             exception_lineno = 6; 820             exception_lineno = 6;
881 821
882             goto frame_exception_exit_1; 822             goto frame_exception_exit_1;
883         } 823         }
n 884         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 824         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
885     } 825     }
886     { 826     {
887         PyObject *tmp_assign_source_5; 827         PyObject *tmp_assign_source_5;
888         { 828         {
889             PyObject *tmp_assign_source_6; 829             PyObject *tmp_assign_source_6;
890             PyObject *tmp_defaults_1; 830             PyObject *tmp_defaults_1;
n 891             tmp_defaults_1 = mod_consts[7]; n 831             tmp_defaults_1 = mod_consts[6];
892             Py_INCREF(tmp_defaults_1); 832             Py_INCREF(tmp_defaults_1);
893 833
894 834
895             tmp_assign_source_6 = MAKE_FUNCTION___main__$$$function__1_compiled_method(tmp_defaults_1); 835             tmp_assign_source_6 = MAKE_FUNCTION___main__$$$function__1_compiled_method(tmp_defaults_1);
896 836
906             tmp_assign_source_5 = _PyDict_NewPresized( 2 ); 846             tmp_assign_source_5 = _PyDict_NewPresized( 2 );
907             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1); 847             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1);
908             assert(!(tmp_res != 0)); 848             assert(!(tmp_res != 0));
909             CHECK_OBJECT(tmp_locals___main__$$$class__1_C_9_key_compiled_method); 849             CHECK_OBJECT(tmp_locals___main__$$$class__1_C_9_key_compiled_method);
910             tmp_dict_value_1 = tmp_locals___main__$$$class__1_C_9_key_compiled_method; 850             tmp_dict_value_1 = tmp_locals___main__$$$class__1_C_9_key_compiled_method;
n 911             tmp_dict_key_1 = mod_consts[1]; n 851             tmp_dict_key_1 = mod_consts[7];
912             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1); 852             tmp_res = PyDict_SetItem(tmp_assign_source_5, tmp_dict_key_1, tmp_dict_value_1);
913             assert(!(tmp_res != 0)); 853             assert(!(tmp_res != 0));
914             goto try_return_handler_1; 854             goto try_return_handler_1;
915         } 855         }
916         NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); 856         NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
1048     } 988     }
1049     { 989     {
1050         PyObject *tmp_assign_source_11; 990         PyObject *tmp_assign_source_11;
1051         PyObject *tmp_iter_arg_1; 991         PyObject *tmp_iter_arg_1;
1052         PyObject *tmp_called_instance_1; 992         PyObject *tmp_called_instance_1;
n 1053         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]); n 993         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]);
1054 994
1055         if (unlikely(tmp_called_instance_1 == NULL)) { 995         if (unlikely(tmp_called_instance_1 == NULL)) {
t 1056             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[6]); t 996             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]);
1057         } 997         }
1058 998
1059         if (tmp_called_instance_1 == NULL) { 999         if (tmp_called_instance_1 == NULL) {
1060             assert(HAS_ERROR_OCCURRED(tstate)); 1000             assert(HAS_ERROR_OCCURRED(tstate));
1061 1001