Construct CallLambdaExpressionDirectly

Performance Diagrams

Construct CallLambdaExpressionDirectly 0040000004000000800000080000001200000012000000160000001600000020000000200000002400000024000000280000002800000032000000320000003600000036000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3873127388.95192307692307255.10059149501865CPython 2.7-300007242.31730769230768502.2159761104033Nuitka (master)-250490395.6826923076923501.9024733889962Nuitka (develop)-250490549.0480769230769501.9024733889962Nuitka (factory)Construct CallLambdaExpressionDirectlyTicks Construct CallLambdaExpressionDirectly 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)5131060688.95192307692307255.5633874840474CPython 3.8-299969242.31730769230768502.6784321464636Nuitka (master)-300040395.6826923076923502.678772099432Nuitka (develop)-300040549.0480769230769502.678772099432Nuitka (factory)Construct CallLambdaExpressionDirectlyTicks

Source Code with Construct

from __future__ import print_function

def calledRepeatedly():
# construct_begin
    return (lambda x : x)(7)
# construct_alternative



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

print("OK.")

Source Code without Construct

from __future__ import print_function

def calledRepeatedly():
# construct_begin

# construct_alternative
    return 7
# construct_end

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
19 # 19 #
20 from __future__ import print_function 20 from __future__ import print_function
21 21
22 def calledRepeatedly(): 22 def calledRepeatedly():
23 # construct_begin 23 # construct_begin
n 24     return (lambda x : x)(7) n 24  
25 # construct_alternative 25 # construct_alternative
t 26   t 26     return 7
27   27 # construct_end
28 28
29 import itertools 29 import itertools
30 for x in itertools.repeat(None, 50000): 30 for x in itertools.repeat(None, 50000):
31     calledRepeatedly() 31     calledRepeatedly()
32 32

Context Diff of Generated Code


Construct
Baseline
82 static PyCodeObject *codeobj_73b42f0ee7620ac6c519151d12178547; 82 static PyCodeObject *codeobj_73b42f0ee7620ac6c519151d12178547;
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_75024eac5e083e53f5f0b15900002254 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0); 88     codeobj_75024eac5e083e53f5f0b15900002254 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0);
89     codeobj_73b42f0ee7620ac6c519151d12178547 = MAKE_CODEOBJECT(module_filename_obj, 22, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], NULL, NULL, 0, 0, 0); 89     codeobj_73b42f0ee7620ac6c519151d12178547 = MAKE_CODEOBJECT(module_filename_obj, 22, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], NULL, NULL, 0, 0, 0);
90 } 90 }
91 91
92 // The module function declarations. 92 // The module function declarations.
n 93 NUITKA_LOCAL_MODULE PyObject *impl___main__$$$function__1_calledRepeatedly$$$function__1_lambda(PyObject **python_pars); n
94  
95  
96 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 93 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
97 94
98 95
99 // The module function definitions. 96 // The module function definitions.
n 100 static PyObject *impl___main__$$$function__1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { n
101     // Preserve error status for checks
102 #ifndef __NUITKA_NO_ASSERT__
103     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
104 #endif
105  
106     // Local variable declarations.
107     PyObject *tmp_return_value = NULL;
108  
109     // Actual function body.
110     {
111         PyObject *tmp_dircall_arg1_1;
112         tmp_dircall_arg1_1 = mod_consts[0];
113         Py_INCREF(tmp_dircall_arg1_1);
114  
115         {
116             PyObject *dir_call_args[] = {tmp_dircall_arg1_1};
117             tmp_return_value = impl___main__$$$function__1_calledRepeatedly$$$function__1_lambda(dir_call_args);
118         }
119         assert(!(tmp_return_value == NULL));
120         goto function_return_exit;
121     }
122  
123     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
124     return NULL;
125  
126  
127 function_return_exit:
128    // Function cleanup code if any.
129  
130  
131    // Actual function exit with return value, making sure we did not make
132    // the error status worse despite non-NULL return.
133    CHECK_OBJECT(tmp_return_value);
134    assert(had_error || !ERROR_OCCURRED());
135    return tmp_return_value;
136 }
137  
138  
139 NUITKA_LOCAL_MODULE PyObject *impl___main__$$$function__1_calledRepeatedly$$$function__1_lambda(PyObject **python_pars) {
140 #ifndef __NUITKA_NO_ASSERT__
141     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
142     assert(!had_error); // Do not enter inlined functions with error set.
143 #endif
144  
145     // Local variable declarations.
146     PyObject *par_x = python_pars[0];
147     PyObject *tmp_return_value = NULL;
148  
149     // Actual function body.
150     CHECK_OBJECT(par_x);
151     tmp_return_value = par_x;
152     Py_INCREF(tmp_return_value);
153     goto function_return_exit;
154  
155     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
156     return NULL;
157  
158  
159 function_return_exit:
160    // Function cleanup code if any.
161     CHECK_OBJECT(par_x);
162     Py_DECREF(par_x);
163  
164    // Actual function exit with return value, making sure we did not make
165    // the error status worse despite non-NULL return.
166    CHECK_OBJECT(tmp_return_value);
167    assert(had_error || !ERROR_OCCURRED());
168    return tmp_return_value;
169 }
170  
171  
172 97
173 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { 98 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() {
174     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 99     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
n 175         impl___main__$$$function__1_calledRepeatedly, n 100         NULL,
176         mod_consts[7], 101         mod_consts[7],
177 #if PYTHON_VERSION >= 0x300 102 #if PYTHON_VERSION >= 0x300
178         NULL, 103         NULL,
179 #endif 104 #endif
180         codeobj_73b42f0ee7620ac6c519151d12178547, 105         codeobj_73b42f0ee7620ac6c519151d12178547,
186         module___main__, 111         module___main__,
187         NULL, 112         NULL,
188         NULL, 113         NULL,
189         0 114         0
190     ); 115     );
n 191   n 116     Nuitka_Function_EnableConstReturnGeneric(result, mod_consts[6]);
192 117
193     return (PyObject *)result; 118     return (PyObject *)result;
194 } 119 }
195 120
196 121
206 // Provide a way to create find a function via its C code and create it back 131 // Provide a way to create find a function via its C code and create it back
207 // in another process, useful for multiprocessing extensions like dill 132 // in another process, useful for multiprocessing extensions like dill
208 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function); 133 extern void registerDillPluginTables(char const *module_name, PyMethodDef *reduce_compiled_function, PyMethodDef *create_compiled_function);
209 134
210 function_impl_code functable___main__[] = { 135 function_impl_code functable___main__[] = {
n 211     impl___main__$$$function__1_calledRepeatedly, n 136     NULL,
212     NULL 137     NULL
213 }; 138 };
214 139
215 static char const *_reduce_compiled_function_argnames[] = { 140 static char const *_reduce_compiled_function_argnames[] = {
216     "func", 141     "func",
551 476
552     // Module code. 477     // Module code.
553     { 478     {
554         PyObject *tmp_assign_source_1; 479         PyObject *tmp_assign_source_1;
555         tmp_assign_source_1 = Py_None; 480         tmp_assign_source_1 = Py_None;
n 556         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); n 481         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
557     } 482     }
558     { 483     {
559         PyObject *tmp_assign_source_2; 484         PyObject *tmp_assign_source_2;
n 560         tmp_assign_source_2 = mod_consts[2]; n 485         tmp_assign_source_2 = mod_consts[1];
561         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); 486         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
562     } 487     }
563     { 488     {
564         PyObject *tmp_assign_source_3; 489         PyObject *tmp_assign_source_3;
565         tmp_assign_source_3 = Py_None; 490         tmp_assign_source_3 = Py_None;
n 566         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 491         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
567     } 492     }
568     { 493     {
569         PyObject *tmp_assign_source_4; 494         PyObject *tmp_assign_source_4;
570         tmp_assign_source_4 = PyDict_New(); 495         tmp_assign_source_4 = PyDict_New();
n 571         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4); n 496         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_4);
572     } 497     }
573     { 498     {
574         PyObject *tmp_assign_source_5; 499         PyObject *tmp_assign_source_5;
575         { 500         {
576             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 501             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 577             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[6]); n 502             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[5]);
578         } 503         }
579 504
580         assert(!(tmp_assign_source_5 == NULL)); 505         assert(!(tmp_assign_source_5 == NULL));
t 581         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5); t 506         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_5);
582     } 507     }
583     { 508     {
584         PyObject *tmp_assign_source_6; 509         PyObject *tmp_assign_source_6;
585 510
586 511