Construct ListCreationConstant

Performance Diagrams

Construct ListCreationConstant 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)2233534188.95192307692307257.0CPython 3.1015971315242.31730769230768327.41077782033005Nuitka (main)16815953395.6826923076923318.06580994046783Nuitka (develop)16615416549.0480769230769320.2845259155056Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2566619188.95192307692307257.0CPython 3.815810211242.31730769230768351.89387375249953Nuitka (main)14958447395.6826923076923360.0947006091818Nuitka (develop)14952633549.0480769230769360.15067809513425Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3051344988.95192307692307257.0CPython 2.716755860242.31730769230768368.4168344953527Nuitka (main)16749551395.6826923076923368.46792839042627Nuitka (develop)16756037549.0480769230769368.41540104798736Nuitka (factory)Construct ListCreationConstantTicks

Source Code with Construct

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

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
4 import itertools 4 import itertools
5 5
6 6
7 def calledRepeatedly(): 7 def calledRepeatedly():
8     # construct_begin 8     # construct_begin
n 9     l = [50, 51, 52, 53, 54, 55, 56, 57] n 9  
10     # construct_alternative 10     # construct_alternative
t 11   t 11     l = 1
12   12     # construct_end
13 13
14     return l 14     return l
15 15
16 16
17 for x in itertools.repeat(None, 50000): 17 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
82 static PyCodeObject *codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5; 82 static PyCodeObject *codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5;
83 /* For use in "MainProgram.c". */ 83 /* For use in "MainProgram.c". */
84 PyCodeObject *codeobj_main = NULL; 84 PyCodeObject *codeobj_main = NULL;
85 85
86 static void createModuleCodeObjects(void) { 86 static void createModuleCodeObjects(void) {
n 87     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj); n 87     module_filename_obj = mod_consts[1]; CHECK_OBJECT(module_filename_obj);
88     codeobj_5d2c39607ea29eb0b071ef784bc45205 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); 88     codeobj_5d2c39607ea29eb0b071ef784bc45205 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_5d2c39607ea29eb0b071ef784bc45205; 89     codeobj_main = codeobj_5d2c39607ea29eb0b071ef784bc45205;
90     codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5 = MAKE_CODE_OBJECT(module_filename_obj, 7, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[5], mod_consts[11], NULL, 0, 0, 0); 90     codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5 = MAKE_CODE_OBJECT(module_filename_obj, 7, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[5], mod_consts[11], NULL, 0, 0, 0);
91 } 91 }
92 92
93 // The module function declarations. 93 // The module function declarations.
94 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 94 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
95 95
96 96
97 // The module function definitions. 97 // The module function definitions.
n 98 static PyObject *impl___main__$$$function__1_calledRepeatedly(PyThreadState *tstate, struct Nuitka_FunctionObject const *self, PyObject **python_pars) { n
99     // Preserve error status for checks
100 #ifndef __NUITKA_NO_ASSERT__
101     NUITKA_MAY_BE_UNUSED bool had_error = HAS_ERROR_OCCURRED(tstate);
102 #endif
103  
104     // Local variable declarations.
105     PyObject *var_l = NULL;
106     PyObject *tmp_return_value = NULL;
107  
108     // Actual function body.
109     {
110         PyObject *tmp_assign_source_1;
111         tmp_assign_source_1 = MAKE_LIST8(mod_consts[0]);
112         assert(var_l == NULL);
113         var_l = tmp_assign_source_1;
114     }
115     // Tried code:
116     CHECK_OBJECT(var_l);
117     tmp_return_value = var_l;
118     Py_INCREF(tmp_return_value);
119     goto try_return_handler_1;
120     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
121     return NULL;
122     // Return handler code:
123     try_return_handler_1:;
124     CHECK_OBJECT(var_l);
125     Py_DECREF(var_l);
126     var_l = NULL;
127     goto function_return_exit;
128     // End of try:
129  
130     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
131     return NULL;
132  
133  
134 function_return_exit:
135    // Function cleanup code if any.
136  
137  
138    // Actual function exit with return value, making sure we did not make
139    // the error status worse despite non-NULL return.
140    CHECK_OBJECT(tmp_return_value);
141    assert(had_error || !HAS_ERROR_OCCURRED(tstate));
142    return tmp_return_value;
143 }
144  
145  
146 98
147 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { 99 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() {
148     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 100     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
n 149         impl___main__$$$function__1_calledRepeatedly, n 101         NULL,
150         mod_consts[5], 102         mod_consts[5],
151 #if PYTHON_VERSION >= 0x300 103 #if PYTHON_VERSION >= 0x300
152         NULL, 104         NULL,
153 #endif 105 #endif
154         codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5, 106         codeobj_8dc6657f266c1bdda3a8c4c8a8f76ae5,
160         module___main__, 112         module___main__,
161         NULL, 113         NULL,
162         NULL, 114         NULL,
163         0 115         0
164     ); 116     );
n 165   n 117     Nuitka_Function_EnableConstReturnGeneric(result, mod_consts[4]);
166 118
167     return (PyObject *)result; 119     return (PyObject *)result;
168 } 120 }
169 121
170 122
180 // Provide a way to create find a function via its C code and create it back 132 // Provide a way to create find a function via its C code and create it back
181 // in another process, useful for multiprocessing extensions like dill 133 // in another process, useful for multiprocessing extensions like dill
182 extern void registerDillPluginTables(PyThreadState *tstate, char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function); 134 extern void registerDillPluginTables(PyThreadState *tstate, char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function);
183 135
184 static function_impl_code const function_table___main__[] = { 136 static function_impl_code const function_table___main__[] = {
n 185     impl___main__$$$function__1_calledRepeatedly, n 137  
186     NULL 138     NULL
187 }; 139 };
188 140
189 static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObject *kwds) { 141 static PyObject *_reduce_compiled_function(PyObject *self, PyObject *args, PyObject *kwds) {
190     PyObject *func; 142     PyObject *func;
535 487
536     // Module code. 488     // Module code.
537     { 489     {
538         PyObject *tmp_assign_source_1; 490         PyObject *tmp_assign_source_1;
539         tmp_assign_source_1 = Py_None; 491         tmp_assign_source_1 = Py_None;
n 540         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 492         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
541     } 493     }
542     { 494     {
543         PyObject *tmp_assign_source_2; 495         PyObject *tmp_assign_source_2;
n 544         tmp_assign_source_2 = mod_consts[2]; n 496         tmp_assign_source_2 = mod_consts[1];
545         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 497         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
546     } 498     }
547     frame_5d2c39607ea29eb0b071ef784bc45205 = MAKE_MODULE_FRAME(codeobj_5d2c39607ea29eb0b071ef784bc45205, module___main__); 499     frame_5d2c39607ea29eb0b071ef784bc45205 = MAKE_MODULE_FRAME(codeobj_5d2c39607ea29eb0b071ef784bc45205, module___main__);
548 500
549     // Push the new frame as the currently active one, and we should be exclusively 501     // Push the new frame as the currently active one, and we should be exclusively
550     // owning it. 502     // owning it.
556         PyObject *tmp_assign_source_3; 508         PyObject *tmp_assign_source_3;
557         PyObject *tmp_name_value_1; 509         PyObject *tmp_name_value_1;
558         PyObject *tmp_globals_arg_value_1; 510         PyObject *tmp_globals_arg_value_1;
559         PyObject *tmp_locals_arg_value_1; 511         PyObject *tmp_locals_arg_value_1;
560         PyObject *tmp_fromlist_value_1; 512         PyObject *tmp_fromlist_value_1;
n 561         tmp_name_value_1 = mod_consts[4]; n 513         tmp_name_value_1 = mod_consts[3];
562         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 514         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
563         tmp_locals_arg_value_1 = Py_None; 515         tmp_locals_arg_value_1 = Py_None;
564         tmp_fromlist_value_1 = Py_None; 516         tmp_fromlist_value_1 = Py_None;
565         frame_5d2c39607ea29eb0b071ef784bc45205->m_frame.f_lineno = 4; 517         frame_5d2c39607ea29eb0b071ef784bc45205->m_frame.f_lineno = 4;
566         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); 518         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1);
572 524
573             exception_lineno = 4; 525             exception_lineno = 4;
574 526
575             goto frame_exception_exit_1; 527             goto frame_exception_exit_1;
576         } 528         }
n 577         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 529         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
578     } 530     }
579     { 531     {
580         PyObject *tmp_assign_source_4; 532         PyObject *tmp_assign_source_4;
581 533
582 534
586     } 538     }
587     { 539     {
588         PyObject *tmp_assign_source_5; 540         PyObject *tmp_assign_source_5;
589         PyObject *tmp_iter_arg_1; 541         PyObject *tmp_iter_arg_1;
590         PyObject *tmp_called_instance_1; 542         PyObject *tmp_called_instance_1;
n 591         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); n 543         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[3]);
592 544
593         if (unlikely(tmp_called_instance_1 == NULL)) { 545         if (unlikely(tmp_called_instance_1 == NULL)) {
t 594             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]); t 546             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[3]);
595         } 547         }
596 548
597         assert(!(tmp_called_instance_1 == NULL)); 549         assert(!(tmp_called_instance_1 == NULL));
598         frame_5d2c39607ea29eb0b071ef784bc45205->m_frame.f_lineno = 17; 550         frame_5d2c39607ea29eb0b071ef784bc45205->m_frame.f_lineno = 17;
599         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 551         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(