Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)1501759188.95192307692307257.0CPython 2.76350514242.31730769230768399.6172857115468Nuitka (main)6350514395.6826923076923399.6172857115468Nuitka (develop)6350514549.0480769230769399.6172857115468Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2317148088.95192307692307257.0CPython 3.811052501242.31730769230768386.2444917946877Nuitka (main)11052515395.6826923076923386.24434248979287Nuitka (develop)11052515549.0480769230769386.24434248979287Nuitka (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_a9b667609c9ed7e513efb9db91ff4407; 81 static PyCodeObject *codeobj_a9b667609c9ed7e513efb9db91ff4407;
82 static PyCodeObject *codeobj_56eba71c97963c6624026961c3a63e05; 82 static PyCodeObject *codeobj_56eba71c97963c6624026961c3a63e05;
n 83 static PyCodeObject *codeobj_cef4894399b0eab1877fa7f53cadfe41; 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_a9b667609c9ed7e513efb9db91ff4407 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0); 88     codeobj_a9b667609c9ed7e513efb9db91ff4407 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], NULL, NULL, 0, 0, 0);
90     codeobj_56eba71c97963c6624026961c3a63e05 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], mod_consts[16], NULL, 0, 0, 0); 89     codeobj_56eba71c97963c6624026961c3a63e05 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[15], NULL, 0, 0, 0);
91     codeobj_cef4894399b0eab1877fa7f53cadfe41 = 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_56eba71c97963c6624026961c3a63e05, 105         codeobj_56eba71c97963c6624026961c3a63e05,
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_cef4894399b0eab1877fa7f53cadfe41,
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",
563 481
564     // Module code. 482     // Module code.
565     { 483     {
566         PyObject *tmp_assign_source_1; 484         PyObject *tmp_assign_source_1;
567         tmp_assign_source_1 = Py_None; 485         tmp_assign_source_1 = Py_None;
n 568         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 486         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
569     } 487     }
570     { 488     {
571         PyObject *tmp_assign_source_2; 489         PyObject *tmp_assign_source_2;
n 572         tmp_assign_source_2 = mod_consts[3]; n 490         tmp_assign_source_2 = mod_consts[1];
573         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 491         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
574     } 492     }
575     { 493     {
576         PyObject *tmp_assign_source_3; 494         PyObject *tmp_assign_source_3;
577         tmp_assign_source_3 = Py_None; 495         tmp_assign_source_3 = Py_None;
n 578         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 496         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
579     } 497     }
580     { 498     {
581         PyObject *tmp_assign_source_4; 499         PyObject *tmp_assign_source_4;
582         tmp_assign_source_4 = PyDict_New(); 500         tmp_assign_source_4 = PyDict_New();
n 583         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 501         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_4);
584     } 502     }
585     { 503     {
586         PyObject *tmp_assign_source_5; 504         PyObject *tmp_assign_source_5;
587 505
588 506
589         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 507         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
590 508
n 591         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5); n 509         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
592     } 510     }
593     { 511     {
594         PyObject *tmp_assign_source_6; 512         PyObject *tmp_assign_source_6;
595         PyObject *tmp_name_value_1; 513         PyObject *tmp_name_value_1;
596         PyObject *tmp_globals_arg_value_1; 514         PyObject *tmp_globals_arg_value_1;
597         PyObject *tmp_locals_arg_value_1; 515         PyObject *tmp_locals_arg_value_1;
598         PyObject *tmp_fromlist_value_1; 516         PyObject *tmp_fromlist_value_1;
599         PyObject *tmp_level_value_1; 517         PyObject *tmp_level_value_1;
n 600         tmp_name_value_1 = mod_consts[8]; n 518         tmp_name_value_1 = mod_consts[7];
601         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 519         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
602         tmp_locals_arg_value_1 = Py_None; 520         tmp_locals_arg_value_1 = Py_None;
603         tmp_fromlist_value_1 = Py_None; 521         tmp_fromlist_value_1 = Py_None;
n 604         tmp_level_value_1 = mod_consts[9]; n 522         tmp_level_value_1 = mod_consts[8];
605         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1, tmp_level_value_1); 523         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1, tmp_level_value_1);
606         assert(!(tmp_assign_source_6 == NULL)); 524         assert(!(tmp_assign_source_6 == NULL));
n 607         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6); n 525         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_6);
608     } 526     }
609     // Frame without reuse. 527     // Frame without reuse.
610     frame_a9b667609c9ed7e513efb9db91ff4407 = MAKE_MODULE_FRAME(codeobj_a9b667609c9ed7e513efb9db91ff4407, module___main__); 528     frame_a9b667609c9ed7e513efb9db91ff4407 = MAKE_MODULE_FRAME(codeobj_a9b667609c9ed7e513efb9db91ff4407, module___main__);
611 529
612     // Push the new frame as the currently active one, and we should be exclusively 530     // Push the new frame as the currently active one, and we should be exclusively
617     // Framed code: 535     // Framed code:
618     { 536     {
619         PyObject *tmp_assign_source_7; 537         PyObject *tmp_assign_source_7;
620         PyObject *tmp_iter_arg_1; 538         PyObject *tmp_iter_arg_1;
621         PyObject *tmp_called_instance_1; 539         PyObject *tmp_called_instance_1;
n 622         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 540         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
623 541
624         if (unlikely(tmp_called_instance_1 == NULL)) { 542         if (unlikely(tmp_called_instance_1 == NULL)) {
n 625             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[8]); n 543             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]);
626         } 544         }
627 545
628         assert(!(tmp_called_instance_1 == NULL)); 546         assert(!(tmp_called_instance_1 == NULL));
629         frame_a9b667609c9ed7e513efb9db91ff4407->m_frame.f_lineno = 36; 547         frame_a9b667609c9ed7e513efb9db91ff4407->m_frame.f_lineno = 36;
630         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 548         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(
631             tmp_called_instance_1, 549             tmp_called_instance_1,
n 632             mod_consts[10], n 550             mod_consts[9],
633             &PyTuple_GET_ITEM(mod_consts[11], 0) 551             &PyTuple_GET_ITEM(mod_consts[10], 0)
634         ); 552         );
635 553
636         if (tmp_iter_arg_1 == NULL) { 554         if (tmp_iter_arg_1 == NULL) {
637             assert(ERROR_OCCURRED()); 555             assert(ERROR_OCCURRED());
638 556
688     } 606     }
689     { 607     {
690         PyObject *tmp_assign_source_9; 608         PyObject *tmp_assign_source_9;
691         CHECK_OBJECT(tmp_for_loop_1__iter_value); 609         CHECK_OBJECT(tmp_for_loop_1__iter_value);
692         tmp_assign_source_9 = tmp_for_loop_1__iter_value; 610         tmp_assign_source_9 = tmp_for_loop_1__iter_value;
n 693         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[12], tmp_assign_source_9); n 611         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_9);
694     } 612     }
695     { 613     {
696         PyObject *tmp_called_value_1; 614         PyObject *tmp_called_value_1;
697         PyObject *tmp_call_result_1; 615         PyObject *tmp_call_result_1;
n 698         tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]); n 616         tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]);
699 617
700         if (unlikely(tmp_called_value_1 == NULL)) { 618         if (unlikely(tmp_called_value_1 == NULL)) {
n 701             tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]); n 619             tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[6]);
702         } 620         }
703 621
704         if (tmp_called_value_1 == NULL) { 622         if (tmp_called_value_1 == NULL) {
705             assert(ERROR_OCCURRED()); 623             assert(ERROR_OCCURRED());
706 624
769     Py_DECREF(tmp_for_loop_1__for_iterator); 687     Py_DECREF(tmp_for_loop_1__for_iterator);
770     tmp_for_loop_1__for_iterator = NULL; 688     tmp_for_loop_1__for_iterator = NULL;
771     { 689     {
772         PyObject *tmp_called_value_2; 690         PyObject *tmp_called_value_2;
773         PyObject *tmp_call_result_2; 691         PyObject *tmp_call_result_2;
n 774         tmp_called_value_2 = LOOKUP_BUILTIN(mod_consts[13]); n 692         tmp_called_value_2 = LOOKUP_BUILTIN(mod_consts[12]);
775         assert(tmp_called_value_2 != NULL); 693         assert(tmp_called_value_2 != NULL);
776         frame_a9b667609c9ed7e513efb9db91ff4407->m_frame.f_lineno = 39; 694         frame_a9b667609c9ed7e513efb9db91ff4407->m_frame.f_lineno = 39;
t 777         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_value_2, mod_consts[14]); t 695         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_value_2, mod_consts[13]);
778 696
779         if (tmp_call_result_2 == NULL) { 697         if (tmp_call_result_2 == NULL) {
780             assert(ERROR_OCCURRED()); 698             assert(ERROR_OCCURRED());
781 699
782             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 700             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);