Construct CallCompiledFunctionPosArgsConstant

Performance Diagrams

Construct CallCompiledFunctionPosArgsConstant 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)17529853988.11538461538461257.0CPython 2.740070324240.03846153846155447.6289268079805Nuitka (master)40070738391.96153846153845447.6283431991849Nuitka (develop)40070738543.8846153846154447.6283431991849Nuitka (factory)Construct CallCompiledFunctionPosArgsConstantTicks Construct CallCompiledFunctionPosArgsConstant 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)16205412988.11538461538461257.0CPython 3.842025815240.03846153846155440.03046742391956Nuitka (master)42025651391.96153846153845440.03071750655135Nuitka (develop)42025651543.8846153846154440.03071750655135Nuitka (factory)Construct CallCompiledFunctionPosArgsConstantTicks

Source Code with Construct

from __future__ import print_function

def compiled_func(a,b,c,d,e,f):
    return a, b, c, d, e, f

def calledRepeatedly():

    compiled_f = compiled_func
    # This is supposed to make a call to a compiled function, which is
    # being optimized separately.
# construct_begin
    compiled_f("some", "random", "values", "to", "check", "call")
    compiled_f("some", "other", "values", "to", "check", "call")
    compiled_f("some", "new", "values", "to", "check", "call")
# construct_alternative



    return compiled_f

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

from __future__ import print_function

def compiled_func(a,b,c,d,e,f):
    return a, b, c, d, e, f

def calledRepeatedly():

    compiled_f = compiled_func
    # This is supposed to make a call to a compiled function, which is
    # being optimized separately.
# construct_begin



# construct_alternative
    pass
# construct_end

    return compiled_f

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
26 26
27     compiled_f = compiled_func 27     compiled_f = compiled_func
28     # This is supposed to make a call to a compiled function, which is 28     # This is supposed to make a call to a compiled function, which is
29     # being optimized separately. 29     # being optimized separately.
30 # construct_begin 30 # construct_begin
n 31     compiled_f("some", "random", "values", "to", "check", "call") n
32     compiled_f("some", "other", "values", "to", "check", "call")
33     compiled_f("some", "new", "values", "to", "check", "call")
34 # construct_alternative
35 31
36 32
t t 33  
34 # construct_alternative
35     pass
36 # construct_end
37 37
38     return compiled_f 38     return compiled_f
39 39
40 import itertools 40 import itertools
41 for x in itertools.repeat(None, 50000): 41 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
31 31
32 PyObject *module___main__; 32 PyObject *module___main__;
33 PyDictObject *moduledict___main__; 33 PyDictObject *moduledict___main__;
34 34
35 /* The declarations of module constants used, if any. */ 35 /* The declarations of module constants used, if any. */
n 36 static PyObject *mod_consts[21]; n 36 static PyObject *mod_consts[18];
37 37
38 static PyObject *module_filename_obj = NULL; 38 static PyObject *module_filename_obj = NULL;
39 39
40 /* Indicator if this modules private constants were created yet. */ 40 /* Indicator if this modules private constants were created yet. */
41 static bool constants_created = false; 41 static bool constants_created = false;
71 static PyCodeObject *codeobj_1ff67357c91207417140c1ca7953d9b6; 71 static PyCodeObject *codeobj_1ff67357c91207417140c1ca7953d9b6;
72 /* For use in "MainProgram.c". */ 72 /* For use in "MainProgram.c". */
73 PyCodeObject *codeobj_main = NULL; 73 PyCodeObject *codeobj_main = NULL;
74 74
75 static void createModuleCodeObjects(void) { 75 static void createModuleCodeObjects(void) {
n 76     module_filename_obj = mod_consts[5]; CHECK_OBJECT(module_filename_obj); n 76     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
77     codeobj_435dcec858cfc5ca4d1fdcf46df8f56f = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[18], NULL, NULL, 0, 0, 0); 77     codeobj_435dcec858cfc5ca4d1fdcf46df8f56f = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0);
78     codeobj_115408f20dbd81fd7278bdffdc5f01cc = MAKE_CODEOBJECT(module_filename_obj, 25, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[10], mod_consts[19], NULL, 0, 0, 0); 78     codeobj_115408f20dbd81fd7278bdffdc5f01cc = MAKE_CODEOBJECT(module_filename_obj, 25, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], mod_consts[16], NULL, 0, 0, 0);
79     codeobj_1ff67357c91207417140c1ca7953d9b6 = MAKE_CODEOBJECT(module_filename_obj, 22, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[0], mod_consts[20], NULL, 6, 0, 0); 79     codeobj_1ff67357c91207417140c1ca7953d9b6 = MAKE_CODEOBJECT(module_filename_obj, 22, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[0], mod_consts[17], NULL, 6, 0, 0);
80 } 80 }
81 81
82 // The module function declarations. 82 // The module function declarations.
83 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_func(); 83 static PyObject *MAKE_FUNCTION___main__$$$function__1_compiled_func();
84 84
180     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 180     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
181     PyObject *exception_type = NULL; 181     PyObject *exception_type = NULL;
182     PyObject *exception_value = NULL; 182     PyObject *exception_value = NULL;
183     PyTracebackObject *exception_tb = NULL; 183     PyTracebackObject *exception_tb = NULL;
184     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 184     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 185     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; n
186     static struct Nuitka_FrameObject *cache_frame_115408f20dbd81fd7278bdffdc5f01cc = NULL; 185     static struct Nuitka_FrameObject *cache_frame_115408f20dbd81fd7278bdffdc5f01cc = NULL;
187     PyObject *tmp_return_value = NULL; 186     PyObject *tmp_return_value = NULL;
188     PyObject *exception_keeper_type_1; 187     PyObject *exception_keeper_type_1;
189     PyObject *exception_keeper_value_1; 188     PyObject *exception_keeper_value_1;
190     PyTracebackObject *exception_keeper_tb_1; 189     PyTracebackObject *exception_keeper_tb_1;
238             goto frame_exception_exit_1; 237             goto frame_exception_exit_1;
239         } 238         }
240         assert(var_compiled_f == NULL); 239         assert(var_compiled_f == NULL);
241         Py_INCREF(tmp_assign_source_1); 240         Py_INCREF(tmp_assign_source_1);
242         var_compiled_f = tmp_assign_source_1; 241         var_compiled_f = tmp_assign_source_1;
n 243     } n
244     {
245         PyObject *tmp_called_name_1;
246         PyObject *tmp_call_result_1;
247         CHECK_OBJECT(var_compiled_f);
248         tmp_called_name_1 = var_compiled_f;
249         frame_115408f20dbd81fd7278bdffdc5f01cc->m_frame.f_lineno = 31;
250         tmp_call_result_1 = CALL_FUNCTION_WITH_ARGS6(tmp_called_name_1, &PyTuple_GET_ITEM(mod_consts[1], 0));
251  
252         if (tmp_call_result_1 == NULL) {
253             assert(ERROR_OCCURRED());
254  
255             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
256  
257  
258             exception_lineno = 31;
259             type_description_1 = "o";
260             goto frame_exception_exit_1;
261         }
262         Py_DECREF(tmp_call_result_1);
263     }
264     {
265         PyObject *tmp_called_name_2;
266         PyObject *tmp_call_result_2;
267         CHECK_OBJECT(var_compiled_f);
268         tmp_called_name_2 = var_compiled_f;
269         frame_115408f20dbd81fd7278bdffdc5f01cc->m_frame.f_lineno = 32;
270         tmp_call_result_2 = CALL_FUNCTION_WITH_ARGS6(tmp_called_name_2, &PyTuple_GET_ITEM(mod_consts[2], 0));
271  
272         if (tmp_call_result_2 == NULL) {
273             assert(ERROR_OCCURRED());
274  
275             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
276  
277  
278             exception_lineno = 32;
279             type_description_1 = "o";
280             goto frame_exception_exit_1;
281         }
282         Py_DECREF(tmp_call_result_2);
283     }
284     {
285         PyObject *tmp_called_name_3;
286         PyObject *tmp_call_result_3;
287         CHECK_OBJECT(var_compiled_f);
288         tmp_called_name_3 = var_compiled_f;
289         frame_115408f20dbd81fd7278bdffdc5f01cc->m_frame.f_lineno = 33;
290         tmp_call_result_3 = CALL_FUNCTION_WITH_ARGS6(tmp_called_name_3, &PyTuple_GET_ITEM(mod_consts[3], 0));
291  
292         if (tmp_call_result_3 == NULL) {
293             assert(ERROR_OCCURRED());
294  
295             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
296  
297  
298             exception_lineno = 33;
299             type_description_1 = "o";
300             goto frame_exception_exit_1;
301         }
302         Py_DECREF(tmp_call_result_3);
303     } 242     }
304 243
305 #if 0 244 #if 0
306     RESTORE_FRAME_EXCEPTION(frame_115408f20dbd81fd7278bdffdc5f01cc); 245     RESTORE_FRAME_EXCEPTION(frame_115408f20dbd81fd7278bdffdc5f01cc);
307 #endif 246 #endif
372     exception_type = NULL; 311     exception_type = NULL;
373     exception_value = NULL; 312     exception_value = NULL;
374     exception_tb = NULL; 313     exception_tb = NULL;
375     exception_lineno = 0; 314     exception_lineno = 0;
376 315
n 377     Py_XDECREF(var_compiled_f); n
378     var_compiled_f = NULL;
379     // Re-raise. 316     // Re-raise.
380     exception_type = exception_keeper_type_1; 317     exception_type = exception_keeper_type_1;
381     exception_value = exception_keeper_value_1; 318     exception_value = exception_keeper_value_1;
382     exception_tb = exception_keeper_tb_1; 319     exception_tb = exception_keeper_tb_1;
383     exception_lineno = exception_keeper_lineno_1; 320     exception_lineno = exception_keeper_lineno_1;
433 370
434 371
435 static PyObject *MAKE_FUNCTION___main__$$$function__2_calledRepeatedly() { 372 static PyObject *MAKE_FUNCTION___main__$$$function__2_calledRepeatedly() {
436     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 373     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
437         impl___main__$$$function__2_calledRepeatedly, 374         impl___main__$$$function__2_calledRepeatedly,
n 438         mod_consts[10], n 375         mod_consts[7],
439 #if PYTHON_VERSION >= 0x300 376 #if PYTHON_VERSION >= 0x300
440         NULL, 377         NULL,
441 #endif 378 #endif
442         codeobj_115408f20dbd81fd7278bdffdc5f01cc, 379         codeobj_115408f20dbd81fd7278bdffdc5f01cc,
443         NULL, 380         NULL,
816 753
817     // Module code. 754     // Module code.
818     { 755     {
819         PyObject *tmp_assign_source_1; 756         PyObject *tmp_assign_source_1;
820         tmp_assign_source_1 = Py_None; 757         tmp_assign_source_1 = Py_None;
n 821         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1); n 758         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
822     } 759     }
823     { 760     {
824         PyObject *tmp_assign_source_2; 761         PyObject *tmp_assign_source_2;
n 825         tmp_assign_source_2 = mod_consts[5]; n 762         tmp_assign_source_2 = mod_consts[2];
826         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2); 763         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
827     } 764     }
828     { 765     {
829         PyObject *tmp_assign_source_3; 766         PyObject *tmp_assign_source_3;
830         tmp_assign_source_3 = Py_None; 767         tmp_assign_source_3 = Py_None;
n 831         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3); n 768         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
832     } 769     }
833     { 770     {
834         PyObject *tmp_assign_source_4; 771         PyObject *tmp_assign_source_4;
835         tmp_assign_source_4 = PyDict_New(); 772         tmp_assign_source_4 = PyDict_New();
n 836         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_4); n 773         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
837     } 774     }
838     { 775     {
839         PyObject *tmp_assign_source_5; 776         PyObject *tmp_assign_source_5;
840         { 777         {
841             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 778             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 842             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[9]); n 779             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[6]);
843         } 780         }
844 781
845         assert(!(tmp_assign_source_5 == NULL)); 782         assert(!(tmp_assign_source_5 == NULL));
n 846         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_5); n 783         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
847     } 784     }
848     { 785     {
849         PyObject *tmp_assign_source_6; 786         PyObject *tmp_assign_source_6;
850 787
851 788
857         PyObject *tmp_assign_source_7; 794         PyObject *tmp_assign_source_7;
858 795
859 796
860         tmp_assign_source_7 = MAKE_FUNCTION___main__$$$function__2_calledRepeatedly(); 797         tmp_assign_source_7 = MAKE_FUNCTION___main__$$$function__2_calledRepeatedly();
861 798
n 862         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_7); n 799         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_7);
863     } 800     }
864     { 801     {
865         PyObject *tmp_assign_source_8; 802         PyObject *tmp_assign_source_8;
866         PyObject *tmp_name_name_1; 803         PyObject *tmp_name_name_1;
867         PyObject *tmp_globals_arg_name_1; 804         PyObject *tmp_globals_arg_name_1;
868         PyObject *tmp_locals_arg_name_1; 805         PyObject *tmp_locals_arg_name_1;
869         PyObject *tmp_fromlist_name_1; 806         PyObject *tmp_fromlist_name_1;
870         PyObject *tmp_level_name_1; 807         PyObject *tmp_level_name_1;
n 871         tmp_name_name_1 = mod_consts[11]; n 808         tmp_name_name_1 = mod_consts[8];
872         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__; 809         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__;
873         tmp_locals_arg_name_1 = Py_None; 810         tmp_locals_arg_name_1 = Py_None;
874         tmp_fromlist_name_1 = Py_None; 811         tmp_fromlist_name_1 = Py_None;
n 875         tmp_level_name_1 = mod_consts[12]; n 812         tmp_level_name_1 = mod_consts[9];
876         tmp_assign_source_8 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1); 813         tmp_assign_source_8 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1);
877         assert(!(tmp_assign_source_8 == NULL)); 814         assert(!(tmp_assign_source_8 == NULL));
n 878         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_8); n 815         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_8);
879     } 816     }
880     // Frame without reuse. 817     // Frame without reuse.
881     frame_435dcec858cfc5ca4d1fdcf46df8f56f = MAKE_MODULE_FRAME(codeobj_435dcec858cfc5ca4d1fdcf46df8f56f, module___main__); 818     frame_435dcec858cfc5ca4d1fdcf46df8f56f = MAKE_MODULE_FRAME(codeobj_435dcec858cfc5ca4d1fdcf46df8f56f, module___main__);
882 819
883     // Push the new frame as the currently active one, and we should be exclusively 820     // Push the new frame as the currently active one, and we should be exclusively
888     // Framed code: 825     // Framed code:
889     { 826     {
890         PyObject *tmp_assign_source_9; 827         PyObject *tmp_assign_source_9;
891         PyObject *tmp_iter_arg_1; 828         PyObject *tmp_iter_arg_1;
892         PyObject *tmp_called_instance_1; 829         PyObject *tmp_called_instance_1;
n 893         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[11]); n 830         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]);
894 831
895         if (unlikely(tmp_called_instance_1 == NULL)) { 832         if (unlikely(tmp_called_instance_1 == NULL)) {
n 896             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[11]); n 833             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[8]);
897         } 834         }
898 835
899         assert(!(tmp_called_instance_1 == NULL)); 836         assert(!(tmp_called_instance_1 == NULL));
900         frame_435dcec858cfc5ca4d1fdcf46df8f56f->m_frame.f_lineno = 41; 837         frame_435dcec858cfc5ca4d1fdcf46df8f56f->m_frame.f_lineno = 41;
901         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 838         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(
902             tmp_called_instance_1, 839             tmp_called_instance_1,
n 903             mod_consts[13], n 840             mod_consts[10],
904             &PyTuple_GET_ITEM(mod_consts[14], 0) 841             &PyTuple_GET_ITEM(mod_consts[11], 0)
905         ); 842         );
906 843
907         if (tmp_iter_arg_1 == NULL) { 844         if (tmp_iter_arg_1 == NULL) {
908             assert(ERROR_OCCURRED()); 845             assert(ERROR_OCCURRED());
909 846
959     } 896     }
960     { 897     {
961         PyObject *tmp_assign_source_11; 898         PyObject *tmp_assign_source_11;
962         CHECK_OBJECT(tmp_for_loop_1__iter_value); 899         CHECK_OBJECT(tmp_for_loop_1__iter_value);
963         tmp_assign_source_11 = tmp_for_loop_1__iter_value; 900         tmp_assign_source_11 = tmp_for_loop_1__iter_value;
n 964         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[15], tmp_assign_source_11); n 901         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[12], tmp_assign_source_11);
965     } 902     }
966     { 903     {
967         PyObject *tmp_called_name_1; 904         PyObject *tmp_called_name_1;
968         PyObject *tmp_call_result_1; 905         PyObject *tmp_call_result_1;
n 969         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[10]); n 906         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
970 907
971         if (unlikely(tmp_called_name_1 == NULL)) { 908         if (unlikely(tmp_called_name_1 == NULL)) {
n 972             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[10]); n 909             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]);
973         } 910         }
974 911
975         if (tmp_called_name_1 == NULL) { 912         if (tmp_called_name_1 == NULL) {
976             assert(ERROR_OCCURRED()); 913             assert(ERROR_OCCURRED());
977 914
1038     Py_XDECREF(tmp_for_loop_1__for_iterator); 975     Py_XDECREF(tmp_for_loop_1__for_iterator);
1039     tmp_for_loop_1__for_iterator = NULL; 976     tmp_for_loop_1__for_iterator = NULL;
1040     { 977     {
1041         PyObject *tmp_called_name_2; 978         PyObject *tmp_called_name_2;
1042         PyObject *tmp_call_result_2; 979         PyObject *tmp_call_result_2;
n 1043         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[16]); n 980         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[13]);
1044         assert(tmp_called_name_2 != NULL); 981         assert(tmp_called_name_2 != NULL);
1045         frame_435dcec858cfc5ca4d1fdcf46df8f56f->m_frame.f_lineno = 44; 982         frame_435dcec858cfc5ca4d1fdcf46df8f56f->m_frame.f_lineno = 44;
t 1046         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[17]); t 983         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[14]);
1047         if (tmp_call_result_2 == NULL) { 984         if (tmp_call_result_2 == NULL) {
1048             assert(ERROR_OCCURRED()); 985             assert(ERROR_OCCURRED());
1049 986
1050             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 987             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
1051 988