Construct ListCreationConstant

Performance Diagrams

Construct ListCreationConstant 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)2234470588.95192307692307257.0CPython 3.1015971464242.31730769230768327.4831816290051Nuitka (main)15971464395.6826923076923327.4831816290051Nuitka (develop)15971464549.0480769230769327.4831816290051Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2566629088.95192307692307257.0CPython 3.815809658242.31730769230768351.89978519265185Nuitka (main)15809658395.6826923076923351.89978519265185Nuitka (develop)15809658549.0480769230769351.89978519265185Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3051351888.95192307692307257.0CPython 2.716755856242.31730769230768368.4171737437309Nuitka (main)16755875395.6826923076923368.4170198711979Nuitka (develop)16755875549.0480769230769368.4170198711979Nuitka (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_23cbb9d7ab0236e3adc5659bb91640bc; 82 static PyCodeObject *codeobj_23cbb9d7ab0236e3adc5659bb91640bc;
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_d8a23457f28811763db0ff5722bbadb9 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); 88     codeobj_d8a23457f28811763db0ff5722bbadb9 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_d8a23457f28811763db0ff5722bbadb9; 89     codeobj_main = codeobj_d8a23457f28811763db0ff5722bbadb9;
90     codeobj_23cbb9d7ab0236e3adc5659bb91640bc = 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_23cbb9d7ab0236e3adc5659bb91640bc = 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(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_23cbb9d7ab0236e3adc5659bb91640bc, 106         codeobj_23cbb9d7ab0236e3adc5659bb91640bc,
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;
532 484
533     // Module code. 485     // Module code.
534     { 486     {
535         PyObject *tmp_assign_source_1; 487         PyObject *tmp_assign_source_1;
536         tmp_assign_source_1 = Py_None; 488         tmp_assign_source_1 = Py_None;
n 537         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 489         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
538     } 490     }
539     { 491     {
540         PyObject *tmp_assign_source_2; 492         PyObject *tmp_assign_source_2;
n 541         tmp_assign_source_2 = mod_consts[2]; n 493         tmp_assign_source_2 = mod_consts[1];
542         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 494         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
543     } 495     }
544     frame_d8a23457f28811763db0ff5722bbadb9 = MAKE_MODULE_FRAME(codeobj_d8a23457f28811763db0ff5722bbadb9, module___main__); 496     frame_d8a23457f28811763db0ff5722bbadb9 = MAKE_MODULE_FRAME(codeobj_d8a23457f28811763db0ff5722bbadb9, module___main__);
545 497
546     // Push the new frame as the currently active one, and we should be exclusively 498     // Push the new frame as the currently active one, and we should be exclusively
547     // owning it. 499     // owning it.
553         PyObject *tmp_assign_source_3; 505         PyObject *tmp_assign_source_3;
554         PyObject *tmp_name_value_1; 506         PyObject *tmp_name_value_1;
555         PyObject *tmp_globals_arg_value_1; 507         PyObject *tmp_globals_arg_value_1;
556         PyObject *tmp_locals_arg_value_1; 508         PyObject *tmp_locals_arg_value_1;
557         PyObject *tmp_fromlist_value_1; 509         PyObject *tmp_fromlist_value_1;
n 558         tmp_name_value_1 = mod_consts[4]; n 510         tmp_name_value_1 = mod_consts[3];
559         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 511         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
560         tmp_locals_arg_value_1 = Py_None; 512         tmp_locals_arg_value_1 = Py_None;
561         tmp_fromlist_value_1 = Py_None; 513         tmp_fromlist_value_1 = Py_None;
562         frame_d8a23457f28811763db0ff5722bbadb9->m_frame.f_lineno = 20; 514         frame_d8a23457f28811763db0ff5722bbadb9->m_frame.f_lineno = 20;
563         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); 515         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);
569 521
570             exception_lineno = 20; 522             exception_lineno = 20;
571 523
572             goto frame_exception_exit_1; 524             goto frame_exception_exit_1;
573         } 525         }
n 574         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 526         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
575     } 527     }
576     { 528     {
577         PyObject *tmp_assign_source_4; 529         PyObject *tmp_assign_source_4;
578 530
579 531
583     } 535     }
584     { 536     {
585         PyObject *tmp_assign_source_5; 537         PyObject *tmp_assign_source_5;
586         PyObject *tmp_iter_arg_1; 538         PyObject *tmp_iter_arg_1;
587         PyObject *tmp_called_instance_1; 539         PyObject *tmp_called_instance_1;
n 588         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); n 540         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[3]);
589 541
590         if (unlikely(tmp_called_instance_1 == NULL)) { 542         if (unlikely(tmp_called_instance_1 == NULL)) {
t 591             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]); t 543             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[3]);
592         } 544         }
593 545
594         assert(!(tmp_called_instance_1 == NULL)); 546         assert(!(tmp_called_instance_1 == NULL));
595         frame_d8a23457f28811763db0ff5722bbadb9->m_frame.f_lineno = 33; 547         frame_d8a23457f28811763db0ff5722bbadb9->m_frame.f_lineno = 33;
596         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 548         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(