Construct ListCreationConstant

Performance Diagrams

Construct ListCreationConstant 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)2233534188.95192307692307257.0CPython 3.1017000242242.31730769230768316.02685978003Nuitka (main)17000813395.6826923076923316.0205423083328Nuitka (develop)17000319549.0480769230769316.02600786178004Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2566619188.95192307692307257.0CPython 3.815806966242.31730769230768351.9251167765648Nuitka (main)15805694395.6826923076923351.9373636568763Nuitka (develop)15805971549.0480769230769351.93469668687135Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3051344988.95192307692307257.0CPython 2.716756052242.31730769230768368.41527956939706Nuitka (main)16756052395.6826923076923368.41527956939706Nuitka (develop)16755994549.0480769230769368.4157492866128Nuitka (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_b27e4bf696bf49b853588e70cc2438db; 82 static PyCodeObject *codeobj_b27e4bf696bf49b853588e70cc2438db;
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_20b6077b9db735c609185670db9cb872 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); 88     codeobj_20b6077b9db735c609185670db9cb872 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_20b6077b9db735c609185670db9cb872; 89     codeobj_main = codeobj_20b6077b9db735c609185670db9cb872;
90     codeobj_b27e4bf696bf49b853588e70cc2438db = 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_b27e4bf696bf49b853588e70cc2438db = 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(tstate, 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_b27e4bf696bf49b853588e70cc2438db, 106         codeobj_b27e4bf696bf49b853588e70cc2438db,
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;
527 479
528     // Module code. 480     // Module code.
529     { 481     {
530         PyObject *tmp_assign_source_1; 482         PyObject *tmp_assign_source_1;
531         tmp_assign_source_1 = Py_None; 483         tmp_assign_source_1 = Py_None;
n 532         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 484         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
533     } 485     }
534     { 486     {
535         PyObject *tmp_assign_source_2; 487         PyObject *tmp_assign_source_2;
n 536         tmp_assign_source_2 = mod_consts[2]; n 488         tmp_assign_source_2 = mod_consts[1];
537         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 489         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
538     } 490     }
539     frame_20b6077b9db735c609185670db9cb872 = MAKE_MODULE_FRAME(codeobj_20b6077b9db735c609185670db9cb872, module___main__); 491     frame_20b6077b9db735c609185670db9cb872 = MAKE_MODULE_FRAME(codeobj_20b6077b9db735c609185670db9cb872, module___main__);
540 492
541     // Push the new frame as the currently active one, and we should be exclusively 493     // Push the new frame as the currently active one, and we should be exclusively
542     // owning it. 494     // owning it.
548         PyObject *tmp_assign_source_3; 500         PyObject *tmp_assign_source_3;
549         PyObject *tmp_name_value_1; 501         PyObject *tmp_name_value_1;
550         PyObject *tmp_globals_arg_value_1; 502         PyObject *tmp_globals_arg_value_1;
551         PyObject *tmp_locals_arg_value_1; 503         PyObject *tmp_locals_arg_value_1;
552         PyObject *tmp_fromlist_value_1; 504         PyObject *tmp_fromlist_value_1;
n 553         tmp_name_value_1 = mod_consts[4]; n 505         tmp_name_value_1 = mod_consts[3];
554         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 506         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
555         tmp_locals_arg_value_1 = Py_None; 507         tmp_locals_arg_value_1 = Py_None;
556         tmp_fromlist_value_1 = Py_None; 508         tmp_fromlist_value_1 = Py_None;
557         frame_20b6077b9db735c609185670db9cb872->m_frame.f_lineno = 4; 509         frame_20b6077b9db735c609185670db9cb872->m_frame.f_lineno = 4;
558         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); 510         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);
564 516
565             exception_lineno = 4; 517             exception_lineno = 4;
566 518
567             goto frame_exception_exit_1; 519             goto frame_exception_exit_1;
568         } 520         }
n 569         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 521         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
570     } 522     }
571     { 523     {
572         PyObject *tmp_assign_source_4; 524         PyObject *tmp_assign_source_4;
573 525
574 526
578     } 530     }
579     { 531     {
580         PyObject *tmp_assign_source_5; 532         PyObject *tmp_assign_source_5;
581         PyObject *tmp_iter_arg_1; 533         PyObject *tmp_iter_arg_1;
582         PyObject *tmp_called_instance_1; 534         PyObject *tmp_called_instance_1;
n 583         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); n 535         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[3]);
584 536
585         if (unlikely(tmp_called_instance_1 == NULL)) { 537         if (unlikely(tmp_called_instance_1 == NULL)) {
t 586             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]); t 538             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[3]);
587         } 539         }
588 540
589         assert(!(tmp_called_instance_1 == NULL)); 541         assert(!(tmp_called_instance_1 == NULL));
590         frame_20b6077b9db735c609185670db9cb872->m_frame.f_lineno = 17; 542         frame_20b6077b9db735c609185670db9cb872->m_frame.f_lineno = 17;
591         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 543         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(