Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1501759188.95192307692307257.0CPython 2.76350547242.31730769230768399.61674269451487Nuitka (master)6350547395.6826923076923399.61674269451487Nuitka (develop)6350522549.0480769230769399.6171540710542Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)2317148088.95192307692307257.0CPython 3.811053264242.31730769230768386.23635467791905Nuitka (master)11053006395.6826923076923386.23910615383824Nuitka (develop)11053180549.0480769230769386.2372505072881Nuitka (factory)Construct FunctionCreationLocalTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin
    def empty():
        pass
# construct_alternative



    return empty


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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin


# construct_alternative
    empty = 1
# construct_end

    return empty


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

print("OK.")

Context Diff of Source Code


Construct
Baseline
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25 # construct_begin 25 # construct_begin
n 26     def empty(): n
27         pass
28 # construct_alternative
29 26
30 27
t t 28 # construct_alternative
29     empty = 1
30 # construct_end
31 31
32     return empty 32     return empty
33 33
34 34
35 import itertools 35 import itertools

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[17]; n 36 static PyObject *mod_consts[16];
37 #ifndef __NUITKA_NO_ASSERT__ 37 #ifndef __NUITKA_NO_ASSERT__
n 38 static Py_hash_t mod_consts_hash[17]; n 38 static Py_hash_t mod_consts_hash[16];
39 #endif 39 #endif
40 40
41 static PyObject *module_filename_obj = NULL; 41 static PyObject *module_filename_obj = NULL;
42 42
43 /* Indicator if this modules private constants were created yet. */ 43 /* Indicator if this modules private constants were created yet. */
48     if (constants_created == false) { 48     if (constants_created == false) {
49         loadConstantsBlob(&mod_consts[0], UNTRANSLATE("__main__")); 49         loadConstantsBlob(&mod_consts[0], UNTRANSLATE("__main__"));
50         constants_created = true; 50         constants_created = true;
51 51
52 #ifndef __NUITKA_NO_ASSERT__ 52 #ifndef __NUITKA_NO_ASSERT__
n 53         for(int i = 0; i < 17; i++) { n 53         for(int i = 0; i < 16; i++) {
54             mod_consts_hash[i] = DEEP_HASH(mod_consts[i]); 54             mod_consts_hash[i] = DEEP_HASH(mod_consts[i]);
55         } 55         }
56 #endif 56 #endif
57     } 57     }
58 } 58 }
68 #ifndef __NUITKA_NO_ASSERT__ 68 #ifndef __NUITKA_NO_ASSERT__
69 void checkModuleConstants___main__(void) { 69 void checkModuleConstants___main__(void) {
70     // The module may not have been used at all, then ignore this. 70     // The module may not have been used at all, then ignore this.
71     if (constants_created == false) return; 71     if (constants_created == false) return;
72 72
n 73     for(int i = 0; i < 17; i++) { n 73     for(int i = 0; i < 16; i++) {
74         assert(mod_consts_hash[i] == DEEP_HASH(mod_consts[i])); 74         assert(mod_consts_hash[i] == DEEP_HASH(mod_consts[i]));
75         CHECK_OBJECT_DEEP(mod_consts[i]); 75         CHECK_OBJECT_DEEP(mod_consts[i]);
76     } 76     }
77 } 77 }
78 #endif 78 #endif
79 79
80 // The module code objects. 80 // The module code objects.
81 static PyCodeObject *codeobj_4b24e41a5b6a77d4d5f16a8960ddd811; 81 static PyCodeObject *codeobj_4b24e41a5b6a77d4d5f16a8960ddd811;
82 static PyCodeObject *codeobj_354558993eb2bff267bbb456adb244db; 82 static PyCodeObject *codeobj_354558993eb2bff267bbb456adb244db;
n 83 static PyCodeObject *codeobj_38779d22e5cdfaa18bbcd4457fcf07a3; n
84 /* For use in "MainProgram.c". */ 83 /* For use in "MainProgram.c". */
85 PyCodeObject *codeobj_main = NULL; 84 PyCodeObject *codeobj_main = NULL;
86 85
87 static void createModuleCodeObjects(void) { 86 static void createModuleCodeObjects(void) {
n 88     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 87     module_filename_obj = mod_consts[1]; CHECK_OBJECT(module_filename_obj);
89     codeobj_4b24e41a5b6a77d4d5f16a8960ddd811 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0); 88     codeobj_4b24e41a5b6a77d4d5f16a8960ddd811 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], NULL, NULL, 0, 0, 0);
90     codeobj_354558993eb2bff267bbb456adb244db = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], mod_consts[16], NULL, 0, 0, 0); 89     codeobj_354558993eb2bff267bbb456adb244db = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[15], NULL, 0, 0, 0);
91     codeobj_38779d22e5cdfaa18bbcd4457fcf07a3 = MAKE_CODEOBJECT(module_filename_obj, 26, CO_NOFREE, mod_consts[0], NULL, NULL, 0, 0, 0);
92 } 90 }
93 91
94 // The module function declarations. 92 // The module function declarations.
95 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 93 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
96 94
97 95
n 98 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty(); n
99  
100  
101 // The module function definitions. 96 // The module function definitions.
n 102 static PyObject *impl___main__$$$function__1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { n
103     // Preserve error status for checks
104 #ifndef __NUITKA_NO_ASSERT__
105     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
106 #endif
107  
108     // Local variable declarations.
109     PyObject *var_empty = NULL;
110     PyObject *tmp_return_value = NULL;
111  
112     // Actual function body.
113     {
114         PyObject *tmp_assign_source_1;
115  
116  
117         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty();
118  
119         assert(var_empty == NULL);
120         var_empty = tmp_assign_source_1;
121     }
122     // Tried code:
123     CHECK_OBJECT(var_empty);
124     tmp_return_value = var_empty;
125     Py_INCREF(tmp_return_value);
126     goto try_return_handler_1;
127     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
128     return NULL;
129     // Return handler code:
130     try_return_handler_1:;
131     CHECK_OBJECT(var_empty);
132     Py_DECREF(var_empty);
133     var_empty = NULL;
134     goto function_return_exit;
135     // End of try:
136  
137     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
138     return NULL;
139  
140  
141 function_return_exit:
142    // Function cleanup code if any.
143  
144  
145    // Actual function exit with return value, making sure we did not make
146    // the error status worse despite non-NULL return.
147    CHECK_OBJECT(tmp_return_value);
148    assert(had_error || !ERROR_OCCURRED());
149    return tmp_return_value;
150 }
151  
152  
153 97
154 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { 98 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() {
155     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 99     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
n 156         impl___main__$$$function__1_calledRepeatedly, n 100         NULL,
157         mod_consts[7], 101         mod_consts[6],
158 #if PYTHON_VERSION >= 0x300 102 #if PYTHON_VERSION >= 0x300
159         NULL, 103         NULL,
160 #endif 104 #endif
161         codeobj_354558993eb2bff267bbb456adb244db, 105         codeobj_354558993eb2bff267bbb456adb244db,
162         NULL, 106         NULL,
167         module___main__, 111         module___main__,
168         NULL, 112         NULL,
169         NULL, 113         NULL,
170         0 114         0
171     ); 115     );
n 172   n 116     Nuitka_Function_EnableConstReturnGeneric(result, mod_consts[5]);
173  
174     return (PyObject *)result;
175 }
176  
177  
178  
179 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty() {
180     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
181         NULL,
182         mod_consts[0],
183 #if PYTHON_VERSION >= 0x300
184         mod_consts[1],
185 #endif
186         codeobj_38779d22e5cdfaa18bbcd4457fcf07a3,
187         NULL,
188 #if PYTHON_VERSION >= 0x300
189         NULL,
190         NULL,
191 #endif
192         module___main__,
193         NULL,
194         NULL,
195         0
196     );
197  
198 117
199     return (PyObject *)result; 118     return (PyObject *)result;
200 } 119 }
201 120
202 121
213 // in another process, useful for multiprocessing extensions like dill 132 // in another process, useful for multiprocessing extensions like dill
214 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function); 133 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function);
215 134
216 function_impl_code functable___main__[] = { 135 function_impl_code functable___main__[] = {
217     NULL, 136     NULL,
n 218     impl___main__$$$function__1_calledRepeatedly, n
219     NULL 137     NULL
220 }; 138 };
221 139
222 static char const *_reduce_compiled_function_argnames[] = { 140 static char const *_reduce_compiled_function_argnames[] = {
223     "func", 141     "func",
558 476
559     // Module code. 477     // Module code.
560     { 478     {
561         PyObject *tmp_assign_source_1; 479         PyObject *tmp_assign_source_1;
562         tmp_assign_source_1 = Py_None; 480         tmp_assign_source_1 = Py_None;
n 563         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 481         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
564     } 482     }
565     { 483     {
566         PyObject *tmp_assign_source_2; 484         PyObject *tmp_assign_source_2;
n 567         tmp_assign_source_2 = mod_consts[3]; n 485         tmp_assign_source_2 = mod_consts[1];
568         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 486         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
569     } 487     }
570     { 488     {
571         PyObject *tmp_assign_source_3; 489         PyObject *tmp_assign_source_3;
572         tmp_assign_source_3 = Py_None; 490         tmp_assign_source_3 = Py_None;
n 573         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 491         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
574     } 492     }
575     { 493     {
576         PyObject *tmp_assign_source_4; 494         PyObject *tmp_assign_source_4;
577         tmp_assign_source_4 = PyDict_New(); 495         tmp_assign_source_4 = PyDict_New();
n 578         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 496         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_4);
579     } 497     }
580     { 498     {
581         PyObject *tmp_assign_source_5; 499         PyObject *tmp_assign_source_5;
582 500
583 501
584         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 502         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
585 503
n 586         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5); n 504         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
587     } 505     }
588     { 506     {
589         PyObject *tmp_assign_source_6; 507         PyObject *tmp_assign_source_6;
590         PyObject *tmp_name_name_1; 508         PyObject *tmp_name_name_1;
591         PyObject *tmp_globals_arg_name_1; 509         PyObject *tmp_globals_arg_name_1;
592         PyObject *tmp_locals_arg_name_1; 510         PyObject *tmp_locals_arg_name_1;
593         PyObject *tmp_fromlist_name_1; 511         PyObject *tmp_fromlist_name_1;
594         PyObject *tmp_level_name_1; 512         PyObject *tmp_level_name_1;
n 595         tmp_name_name_1 = mod_consts[8]; n 513         tmp_name_name_1 = mod_consts[7];
596         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__; 514         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__;
597         tmp_locals_arg_name_1 = Py_None; 515         tmp_locals_arg_name_1 = Py_None;
598         tmp_fromlist_name_1 = Py_None; 516         tmp_fromlist_name_1 = Py_None;
n 599         tmp_level_name_1 = mod_consts[9]; n 517         tmp_level_name_1 = mod_consts[8];
600         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1); 518         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1);
601         assert(!(tmp_assign_source_6 == NULL)); 519         assert(!(tmp_assign_source_6 == NULL));
n 602         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6); n 520         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_6);
603     } 521     }
604     // Frame without reuse. 522     // Frame without reuse.
605     frame_4b24e41a5b6a77d4d5f16a8960ddd811 = MAKE_MODULE_FRAME(codeobj_4b24e41a5b6a77d4d5f16a8960ddd811, module___main__); 523     frame_4b24e41a5b6a77d4d5f16a8960ddd811 = MAKE_MODULE_FRAME(codeobj_4b24e41a5b6a77d4d5f16a8960ddd811, module___main__);
606 524
607     // Push the new frame as the currently active one, and we should be exclusively 525     // Push the new frame as the currently active one, and we should be exclusively
612     // Framed code: 530     // Framed code:
613     { 531     {
614         PyObject *tmp_assign_source_7; 532         PyObject *tmp_assign_source_7;
615         PyObject *tmp_iter_arg_1; 533         PyObject *tmp_iter_arg_1;
616         PyObject *tmp_called_instance_1; 534         PyObject *tmp_called_instance_1;
n 617         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 535         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
618 536
619         if (unlikely(tmp_called_instance_1 == NULL)) { 537         if (unlikely(tmp_called_instance_1 == NULL)) {
n 620             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[8]); n 538             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]);
621         } 539         }
622 540
623         assert(!(tmp_called_instance_1 == NULL)); 541         assert(!(tmp_called_instance_1 == NULL));
624         frame_4b24e41a5b6a77d4d5f16a8960ddd811->m_frame.f_lineno = 36; 542         frame_4b24e41a5b6a77d4d5f16a8960ddd811->m_frame.f_lineno = 36;
625         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 543         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(
626             tmp_called_instance_1, 544             tmp_called_instance_1,
n 627             mod_consts[10], n 545             mod_consts[9],
628             &PyTuple_GET_ITEM(mod_consts[11], 0) 546             &PyTuple_GET_ITEM(mod_consts[10], 0)
629         ); 547         );
630 548
631         if (tmp_iter_arg_1 == NULL) { 549         if (tmp_iter_arg_1 == NULL) {
632             assert(ERROR_OCCURRED()); 550             assert(ERROR_OCCURRED());
633 551
683     } 601     }
684     { 602     {
685         PyObject *tmp_assign_source_9; 603         PyObject *tmp_assign_source_9;
686         CHECK_OBJECT(tmp_for_loop_1__iter_value); 604         CHECK_OBJECT(tmp_for_loop_1__iter_value);
687         tmp_assign_source_9 = tmp_for_loop_1__iter_value; 605         tmp_assign_source_9 = tmp_for_loop_1__iter_value;
n 688         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[12], tmp_assign_source_9); n 606         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_9);
689     } 607     }
690     { 608     {
691         PyObject *tmp_called_name_1; 609         PyObject *tmp_called_name_1;
692         PyObject *tmp_call_result_1; 610         PyObject *tmp_call_result_1;
n 693         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]); n 611         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]);
694 612
695         if (unlikely(tmp_called_name_1 == NULL)) { 613         if (unlikely(tmp_called_name_1 == NULL)) {
n 696             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]); n 614             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[6]);
697         } 615         }
698 616
699         if (tmp_called_name_1 == NULL) { 617         if (tmp_called_name_1 == NULL) {
700             assert(ERROR_OCCURRED()); 618             assert(ERROR_OCCURRED());
701 619
764     Py_DECREF(tmp_for_loop_1__for_iterator); 682     Py_DECREF(tmp_for_loop_1__for_iterator);
765     tmp_for_loop_1__for_iterator = NULL; 683     tmp_for_loop_1__for_iterator = NULL;
766     { 684     {
767         PyObject *tmp_called_name_2; 685         PyObject *tmp_called_name_2;
768         PyObject *tmp_call_result_2; 686         PyObject *tmp_call_result_2;
n 769         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[13]); n 687         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[12]);
770         assert(tmp_called_name_2 != NULL); 688         assert(tmp_called_name_2 != NULL);
771         frame_4b24e41a5b6a77d4d5f16a8960ddd811->m_frame.f_lineno = 39; 689         frame_4b24e41a5b6a77d4d5f16a8960ddd811->m_frame.f_lineno = 39;
t 772         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_name_2, mod_consts[14]); t 690         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_name_2, mod_consts[13]);
773 691
774         if (tmp_call_result_2 == NULL) { 692         if (tmp_call_result_2 == NULL) {
775             assert(ERROR_OCCURRED()); 693             assert(ERROR_OCCURRED());
776 694
777             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 695             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);