Construct ListCreationConstant

Performance Diagrams

Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)2419580088.95192307692307257.0CPython 3.1016608058242.31730769230768334.4947628386872Nuitka (main)16606517395.6826923076923334.5105013060118Nuitka (develop)16606517549.0480769230769334.5105013060118Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2566624988.95192307692307257.0CPython 3.815805230242.31730769230768351.94217495063714Nuitka (main)15805651395.6826923076923351.9381215505114Nuitka (develop)15805651549.0480769230769351.9381215505114Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3051346288.95192307692307257.0CPython 2.716760650242.31730769230768368.3781001619245Nuitka (main)16760650395.6826923076923368.3781001619245Nuitka (develop)16760650549.0480769230769368.3781001619245Nuitka (factory)Construct ListCreationConstantTicks

Source Code with Construct

import itertools


def calledRepeatedly():
    # construct_begin
    l = [50, 51, 52, 53, 54, 55, 56, 57]
    # construct_alternative



    return l


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

print("OK.")

Source Code without Construct

import itertools


def calledRepeatedly():
    # construct_begin

    # construct_alternative
    l = 1
    # construct_end

    return l


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

print("OK.")

Context Diff of Source Code


Construct
Baseline
20 import itertools 20 import itertools
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # construct_begin 24     # construct_begin
n 25     l = [50, 51, 52, 53, 54, 55, 56, 57] n 25  
26     # construct_alternative 26     # construct_alternative
t 27   t 27     l = 1
28   28     # construct_end
29 29
30     return l 30     return l
31 31
32 32
33 for x in itertools.repeat(None, 50000): 33 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
82 static PyCodeObject *codeobj_5264e12d5b47d0aa137c70a8598f82da; 82 static PyCodeObject *codeobj_5264e12d5b47d0aa137c70a8598f82da;
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_d7258b2c2abf224cd586e250dee4bf62 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); 88     codeobj_d7258b2c2abf224cd586e250dee4bf62 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_d7258b2c2abf224cd586e250dee4bf62; 89     codeobj_main = codeobj_d7258b2c2abf224cd586e250dee4bf62;
90     codeobj_5264e12d5b47d0aa137c70a8598f82da = MAKE_CODE_OBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[5], mod_consts[11], NULL, 0, 0, 0); 90     codeobj_5264e12d5b47d0aa137c70a8598f82da = MAKE_CODE_OBJECT(module_filename_obj, 23, 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(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 = ERROR_OCCURRED();
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 || !ERROR_OCCURRED());
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_5264e12d5b47d0aa137c70a8598f82da, 106         codeobj_5264e12d5b47d0aa137c70a8598f82da,
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(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function); 134 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function);
183 135
184 function_impl_code functable___main__[] = { 136 function_impl_code functable___main__[] = {
n 185     impl___main__$$$function__1_calledRepeatedly, n 137     NULL,
186     NULL 138     NULL
187 }; 139 };
188 140
189 static char const *_reduce_compiled_function_argnames[] = { 141 static char const *_reduce_compiled_function_argnames[] = {
190     "func", 142     "func",
529 481
530     // Module code. 482     // Module code.
531     { 483     {
532         PyObject *tmp_assign_source_1; 484         PyObject *tmp_assign_source_1;
533         tmp_assign_source_1 = Py_None; 485         tmp_assign_source_1 = Py_None;
n 534         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 486         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
535     } 487     }
536     { 488     {
537         PyObject *tmp_assign_source_2; 489         PyObject *tmp_assign_source_2;
n 538         tmp_assign_source_2 = mod_consts[2]; n 490         tmp_assign_source_2 = mod_consts[1];
539         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 491         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
540     } 492     }
541     { 493     {
542         PyObject *tmp_assign_source_3; 494         PyObject *tmp_assign_source_3;
543         PyObject *tmp_name_value_1; 495         PyObject *tmp_name_value_1;
544         PyObject *tmp_globals_arg_value_1; 496         PyObject *tmp_globals_arg_value_1;
545         PyObject *tmp_locals_arg_value_1; 497         PyObject *tmp_locals_arg_value_1;
546         PyObject *tmp_fromlist_value_1; 498         PyObject *tmp_fromlist_value_1;
n 547         tmp_name_value_1 = mod_consts[4]; n 499         tmp_name_value_1 = mod_consts[3];
548         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 500         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
549         tmp_locals_arg_value_1 = Py_None; 501         tmp_locals_arg_value_1 = Py_None;
550         tmp_fromlist_value_1 = Py_None; 502         tmp_fromlist_value_1 = Py_None;
551         tmp_assign_source_3 = IMPORT_MODULE4(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); 503         tmp_assign_source_3 = IMPORT_MODULE4(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1);
552         assert(!(tmp_assign_source_3 == NULL)); 504         assert(!(tmp_assign_source_3 == NULL));
n 553         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 505         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
554     } 506     }
555     { 507     {
556         PyObject *tmp_assign_source_4; 508         PyObject *tmp_assign_source_4;
557 509
558 510
570     // Framed code: 522     // Framed code:
571     { 523     {
572         PyObject *tmp_assign_source_5; 524         PyObject *tmp_assign_source_5;
573         PyObject *tmp_iter_arg_1; 525         PyObject *tmp_iter_arg_1;
574         PyObject *tmp_called_instance_1; 526         PyObject *tmp_called_instance_1;
n 575         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); n 527         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[3]);
576 528
577         if (unlikely(tmp_called_instance_1 == NULL)) { 529         if (unlikely(tmp_called_instance_1 == NULL)) {
t 578             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[4]); t 530             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[3]);
579         } 531         }
580 532
581         assert(!(tmp_called_instance_1 == NULL)); 533         assert(!(tmp_called_instance_1 == NULL));
582         frame_d7258b2c2abf224cd586e250dee4bf62->m_frame.f_lineno = 33; 534         frame_d7258b2c2abf224cd586e250dee4bf62->m_frame.f_lineno = 33;
583         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 535         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(