Construct ListCreationConstant

Performance Diagrams

Construct ListCreationConstant 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)2234470588.95192307692307257.0CPython 3.1016001845242.31730769230768327.14719095470446Nuitka (main)15998231395.6826923076923327.18715903662815Nuitka (develop)15998296549.0480769230769327.18644018623377Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)2566629088.95192307692307257.0CPython 3.815808465242.31730769230768351.9112714126644Nuitka (main)15803956395.6826923076923351.9546841251846Nuitka (develop)15804155549.0480769230769351.95276815051363Nuitka (factory)Construct ListCreationConstantTicks Construct ListCreationConstant 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3051351888.95192307692307257.0CPython 2.716760635242.31730769230768368.3784707523854Nuitka (main)16756272395.6826923076923368.4138047451121Nuitka (develop)16756272549.0480769230769368.4138047451121Nuitka (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_a827011490735824ec608112649481e7; 82 static PyCodeObject *codeobj_a827011490735824ec608112649481e7;
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_384d25b7fe7c81bb6cb90de19d42cdbb = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); 88     codeobj_384d25b7fe7c81bb6cb90de19d42cdbb = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0);
89     codeobj_main = codeobj_384d25b7fe7c81bb6cb90de19d42cdbb; 89     codeobj_main = codeobj_384d25b7fe7c81bb6cb90de19d42cdbb;
90     codeobj_a827011490735824ec608112649481e7 = 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_a827011490735824ec608112649481e7 = 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_a827011490735824ec608112649481e7, 106         codeobj_a827011490735824ec608112649481e7,
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 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",
530 482
531     // Module code. 483     // Module code.
532     { 484     {
533         PyObject *tmp_assign_source_1; 485         PyObject *tmp_assign_source_1;
534         tmp_assign_source_1 = Py_None; 486         tmp_assign_source_1 = Py_None;
n 535         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 487         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
536     } 488     }
537     { 489     {
538         PyObject *tmp_assign_source_2; 490         PyObject *tmp_assign_source_2;
n 539         tmp_assign_source_2 = mod_consts[2]; n 491         tmp_assign_source_2 = mod_consts[1];
540         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 492         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
541     } 493     }
542     frame_384d25b7fe7c81bb6cb90de19d42cdbb = MAKE_MODULE_FRAME(codeobj_384d25b7fe7c81bb6cb90de19d42cdbb, module___main__); 494     frame_384d25b7fe7c81bb6cb90de19d42cdbb = MAKE_MODULE_FRAME(codeobj_384d25b7fe7c81bb6cb90de19d42cdbb, module___main__);
543 495
544     // Push the new frame as the currently active one, and we should be exclusively 496     // Push the new frame as the currently active one, and we should be exclusively
545     // owning it. 497     // owning it.
548 500
549     // Framed code: 501     // Framed code:
550     { 502     {
551         PyObject *tmp_assign_source_3; 503         PyObject *tmp_assign_source_3;
552         frame_384d25b7fe7c81bb6cb90de19d42cdbb->m_frame.f_lineno = 20; 504         frame_384d25b7fe7c81bb6cb90de19d42cdbb->m_frame.f_lineno = 20;
n 553         tmp_assign_source_3 = IMPORT_MODULE_FIXED(tstate, mod_consts[4], mod_consts[4]); n 505         tmp_assign_source_3 = IMPORT_MODULE_FIXED(tstate, mod_consts[3], mod_consts[3]);
554         if (tmp_assign_source_3 == NULL) { 506         if (tmp_assign_source_3 == NULL) {
555             assert(HAS_ERROR_OCCURRED(tstate)); 507             assert(HAS_ERROR_OCCURRED(tstate));
556 508
557             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); 509             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
558 510
559 511
560             exception_lineno = 20; 512             exception_lineno = 20;
561 513
562             goto frame_exception_exit_1; 514             goto frame_exception_exit_1;
563         } 515         }
n 564         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 516         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
565     } 517     }
566     { 518     {
567         PyObject *tmp_assign_source_4; 519         PyObject *tmp_assign_source_4;
568 520
569 521
573     } 525     }
574     { 526     {
575         PyObject *tmp_assign_source_5; 527         PyObject *tmp_assign_source_5;
576         PyObject *tmp_iter_arg_1; 528         PyObject *tmp_iter_arg_1;
577         PyObject *tmp_called_instance_1; 529         PyObject *tmp_called_instance_1;
n 578         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); n 530         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[3]);
579 531
580         if (unlikely(tmp_called_instance_1 == NULL)) { 532         if (unlikely(tmp_called_instance_1 == NULL)) {
t 581             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]); t 533             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[3]);
582         } 534         }
583 535
584         assert(!(tmp_called_instance_1 == NULL)); 536         assert(!(tmp_called_instance_1 == NULL));
585         frame_384d25b7fe7c81bb6cb90de19d42cdbb->m_frame.f_lineno = 33; 537         frame_384d25b7fe7c81bb6cb90de19d42cdbb->m_frame.f_lineno = 33;
586         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 538         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(