Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1501821688.95192307692307257.0CPython 2.78300680242.31730769230768367.5328683718287Nuitka (master)8300680395.6826923076923367.5328683718287Nuitka (develop)8300680549.0480769230769367.5328683718287Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)2317127888.95192307692307257.0CPython 3.810902988242.31730769230768387.83797975765845Nuitka (master)10902988395.6826923076923387.83797975765845Nuitka (develop)10902988549.0480769230769387.83797975765845Nuitka (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 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;
66 #endif 66 #endif
67 67
68 // The module code objects. 68 // The module code objects.
69 static PyCodeObject *codeobj_27e2d59ee8f20213dddf20e8f79ba51f; 69 static PyCodeObject *codeobj_27e2d59ee8f20213dddf20e8f79ba51f;
70 static PyCodeObject *codeobj_4ab7bf4a25dddc1fdcbaa94612e96637; 70 static PyCodeObject *codeobj_4ab7bf4a25dddc1fdcbaa94612e96637;
n 71 static PyCodeObject *codeobj_059617e82b73d8c12d639268ade6ce0b; n
72 /* For use in "MainProgram.c". */ 71 /* For use in "MainProgram.c". */
73 PyCodeObject *codeobj_main = NULL; 72 PyCodeObject *codeobj_main = NULL;
74 73
75 static void createModuleCodeObjects(void) { 74 static void createModuleCodeObjects(void) {
n 76     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 75     module_filename_obj = mod_consts[1]; CHECK_OBJECT(module_filename_obj);
77     codeobj_27e2d59ee8f20213dddf20e8f79ba51f = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0); 76     codeobj_27e2d59ee8f20213dddf20e8f79ba51f = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], NULL, NULL, 0, 0, 0);
78     codeobj_4ab7bf4a25dddc1fdcbaa94612e96637 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], mod_consts[16], NULL, 0, 0, 0); 77     codeobj_4ab7bf4a25dddc1fdcbaa94612e96637 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[15], NULL, 0, 0, 0);
79     codeobj_059617e82b73d8c12d639268ade6ce0b = MAKE_CODEOBJECT(module_filename_obj, 26, CO_NOFREE, mod_consts[0], NULL, NULL, 0, 0, 0);
80 } 78 }
81 79
82 // The module function declarations. 80 // The module function declarations.
83 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 81 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
84 82
85 83
n 86 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty(); n
87  
88  
89 // The module function definitions. 84 // The module function definitions.
n 90 static PyObject *impl___main__$$$function__1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { n
91     // Preserve error status for checks
92 #ifndef __NUITKA_NO_ASSERT__
93     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
94 #endif
95  
96     // Local variable declarations.
97     PyObject *var_empty = NULL;
98     PyObject *tmp_return_value = NULL;
99  
100     // Actual function body.
101     {
102         PyObject *tmp_assign_source_1;
103  
104  
105         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty();
106  
107         assert(var_empty == NULL);
108         var_empty = tmp_assign_source_1;
109     }
110     // Tried code:
111     CHECK_OBJECT(var_empty);
112     tmp_return_value = var_empty;
113     Py_INCREF(tmp_return_value);
114     goto try_return_handler_1;
115     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
116     return NULL;
117     // Return handler code:
118     try_return_handler_1:;
119     CHECK_OBJECT(var_empty);
120     Py_DECREF(var_empty);
121     var_empty = NULL;
122     goto function_return_exit;
123     // End of try:
124  
125     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
126     return NULL;
127  
128  
129 function_return_exit:
130    // Function cleanup code if any.
131  
132  
133    // Actual function exit with return value, making sure we did not make
134    // the error status worse despite non-NULL return.
135    CHECK_OBJECT(tmp_return_value);
136    assert(had_error || !ERROR_OCCURRED());
137    return tmp_return_value;
138 }
139  
140  
141 85
142 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { 86 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() {
143     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 87     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
n 144         impl___main__$$$function__1_calledRepeatedly, n 88         NULL,
145         mod_consts[7], 89         mod_consts[6],
146 #if PYTHON_VERSION >= 0x300 90 #if PYTHON_VERSION >= 0x300
147         NULL, 91         NULL,
148 #endif 92 #endif
149         codeobj_4ab7bf4a25dddc1fdcbaa94612e96637, 93         codeobj_4ab7bf4a25dddc1fdcbaa94612e96637,
150         NULL, 94         NULL,
155         module___main__, 99         module___main__,
156         NULL, 100         NULL,
157         NULL, 101         NULL,
158         0 102         0
159     ); 103     );
n 160   n 104     Nuitka_Function_EnableConstReturnGeneric(result, mod_consts[5]);
161  
162     return (PyObject *)result;
163 }
164  
165  
166  
167 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly$$$function__1_empty() {
168     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
169         NULL,
170         mod_consts[0],
171 #if PYTHON_VERSION >= 0x300
172         mod_consts[1],
173 #endif
174         codeobj_059617e82b73d8c12d639268ade6ce0b,
175         NULL,
176 #if PYTHON_VERSION >= 0x300
177         NULL,
178         NULL,
179 #endif
180         module___main__,
181         NULL,
182         NULL,
183         0
184     );
185  
186 105
187     return (PyObject *)result; 106     return (PyObject *)result;
188 } 107 }
189 108
190 109
201 // in another process, useful for multiprocessing extensions like dill 120 // in another process, useful for multiprocessing extensions like dill
202 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function); 121 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function);
203 122
204 function_impl_code functable___main__[] = { 123 function_impl_code functable___main__[] = {
205     NULL, 124     NULL,
n 206     impl___main__$$$function__1_calledRepeatedly, n
207     NULL 125     NULL
208 }; 126 };
209 127
210 static char const *_reduce_compiled_function_argnames[] = { 128 static char const *_reduce_compiled_function_argnames[] = {
211     "func", 129     "func",
548 466
549     // Module code. 467     // Module code.
550     { 468     {
551         PyObject *tmp_assign_source_1; 469         PyObject *tmp_assign_source_1;
552         tmp_assign_source_1 = Py_None; 470         tmp_assign_source_1 = Py_None;
n 553         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 471         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
554     } 472     }
555     { 473     {
556         PyObject *tmp_assign_source_2; 474         PyObject *tmp_assign_source_2;
n 557         tmp_assign_source_2 = mod_consts[3]; n 475         tmp_assign_source_2 = mod_consts[1];
558         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 476         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
559     } 477     }
560     { 478     {
561         PyObject *tmp_assign_source_3; 479         PyObject *tmp_assign_source_3;
562         tmp_assign_source_3 = Py_None; 480         tmp_assign_source_3 = Py_None;
n 563         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 481         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
564     } 482     }
565     { 483     {
566         PyObject *tmp_assign_source_4; 484         PyObject *tmp_assign_source_4;
567         tmp_assign_source_4 = PyDict_New(); 485         tmp_assign_source_4 = PyDict_New();
n 568         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 486         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_4);
569     } 487     }
570     { 488     {
571         PyObject *tmp_assign_source_5; 489         PyObject *tmp_assign_source_5;
572 490
573 491
574         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 492         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
575 493
n 576         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5); n 494         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
577     } 495     }
578     { 496     {
579         PyObject *tmp_assign_source_6; 497         PyObject *tmp_assign_source_6;
580         PyObject *tmp_name_name_1; 498         PyObject *tmp_name_name_1;
581         PyObject *tmp_globals_arg_name_1; 499         PyObject *tmp_globals_arg_name_1;
582         PyObject *tmp_locals_arg_name_1; 500         PyObject *tmp_locals_arg_name_1;
583         PyObject *tmp_fromlist_name_1; 501         PyObject *tmp_fromlist_name_1;
584         PyObject *tmp_level_name_1; 502         PyObject *tmp_level_name_1;
n 585         tmp_name_name_1 = mod_consts[8]; n 503         tmp_name_name_1 = mod_consts[7];
586         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__; 504         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__;
587         tmp_locals_arg_name_1 = Py_None; 505         tmp_locals_arg_name_1 = Py_None;
588         tmp_fromlist_name_1 = Py_None; 506         tmp_fromlist_name_1 = Py_None;
n 589         tmp_level_name_1 = mod_consts[9]; n 507         tmp_level_name_1 = mod_consts[8];
590         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); 508         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);
591         assert(!(tmp_assign_source_6 == NULL)); 509         assert(!(tmp_assign_source_6 == NULL));
n 592         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_6); n 510         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_6);
593     } 511     }
594     // Frame without reuse. 512     // Frame without reuse.
595     frame_27e2d59ee8f20213dddf20e8f79ba51f = MAKE_MODULE_FRAME(codeobj_27e2d59ee8f20213dddf20e8f79ba51f, module___main__); 513     frame_27e2d59ee8f20213dddf20e8f79ba51f = MAKE_MODULE_FRAME(codeobj_27e2d59ee8f20213dddf20e8f79ba51f, module___main__);
596 514
597     // Push the new frame as the currently active one, and we should be exclusively 515     // Push the new frame as the currently active one, and we should be exclusively
602     // Framed code: 520     // Framed code:
603     { 521     {
604         PyObject *tmp_assign_source_7; 522         PyObject *tmp_assign_source_7;
605         PyObject *tmp_iter_arg_1; 523         PyObject *tmp_iter_arg_1;
606         PyObject *tmp_called_instance_1; 524         PyObject *tmp_called_instance_1;
n 607         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 525         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
608 526
609         if (unlikely(tmp_called_instance_1 == NULL)) { 527         if (unlikely(tmp_called_instance_1 == NULL)) {
n 610             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[8]); n 528             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]);
611         } 529         }
612 530
613         assert(!(tmp_called_instance_1 == NULL)); 531         assert(!(tmp_called_instance_1 == NULL));
614         frame_27e2d59ee8f20213dddf20e8f79ba51f->m_frame.f_lineno = 36; 532         frame_27e2d59ee8f20213dddf20e8f79ba51f->m_frame.f_lineno = 36;
615         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 533         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(
616             tmp_called_instance_1, 534             tmp_called_instance_1,
n 617             mod_consts[10], n 535             mod_consts[9],
618             &PyTuple_GET_ITEM(mod_consts[11], 0) 536             &PyTuple_GET_ITEM(mod_consts[10], 0)
619         ); 537         );
620 538
621         if (tmp_iter_arg_1 == NULL) { 539         if (tmp_iter_arg_1 == NULL) {
622             assert(ERROR_OCCURRED()); 540             assert(ERROR_OCCURRED());
623 541
673     } 591     }
674     { 592     {
675         PyObject *tmp_assign_source_9; 593         PyObject *tmp_assign_source_9;
676         CHECK_OBJECT(tmp_for_loop_1__iter_value); 594         CHECK_OBJECT(tmp_for_loop_1__iter_value);
677         tmp_assign_source_9 = tmp_for_loop_1__iter_value; 595         tmp_assign_source_9 = tmp_for_loop_1__iter_value;
n 678         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[12], tmp_assign_source_9); n 596         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_9);
679     } 597     }
680     { 598     {
681         PyObject *tmp_called_name_1; 599         PyObject *tmp_called_name_1;
682         PyObject *tmp_call_result_1; 600         PyObject *tmp_call_result_1;
n 683         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]); n 601         tmp_called_name_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]);
684 602
685         if (unlikely(tmp_called_name_1 == NULL)) { 603         if (unlikely(tmp_called_name_1 == NULL)) {
n 686             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]); n 604             tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[6]);
687         } 605         }
688 606
689         if (tmp_called_name_1 == NULL) { 607         if (tmp_called_name_1 == NULL) {
690             assert(ERROR_OCCURRED()); 608             assert(ERROR_OCCURRED());
691 609
752     Py_XDECREF(tmp_for_loop_1__for_iterator); 670     Py_XDECREF(tmp_for_loop_1__for_iterator);
753     tmp_for_loop_1__for_iterator = NULL; 671     tmp_for_loop_1__for_iterator = NULL;
754     { 672     {
755         PyObject *tmp_called_name_2; 673         PyObject *tmp_called_name_2;
756         PyObject *tmp_call_result_2; 674         PyObject *tmp_call_result_2;
n 757         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[13]); n 675         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[12]);
758         assert(tmp_called_name_2 != NULL); 676         assert(tmp_called_name_2 != NULL);
759         frame_27e2d59ee8f20213dddf20e8f79ba51f->m_frame.f_lineno = 39; 677         frame_27e2d59ee8f20213dddf20e8f79ba51f->m_frame.f_lineno = 39;
t 760         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[14]); t 678         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[13]);
761         if (tmp_call_result_2 == NULL) { 679         if (tmp_call_result_2 == NULL) {
762             assert(ERROR_OCCURRED()); 680             assert(ERROR_OCCURRED());
763 681
764             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 682             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
765 683