Construct CallLambdaExpressionDirectly

Performance Diagrams

Construct CallLambdaExpressionDirectly 0040000004000000800000080000001200000012000000160000001600000020000000200000002400000024000000280000002800000032000000320000003600000036000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)3873127388.95192307692307255.10068573330793CPython 2.7-299992242.31730769230768502.2160703486926Nuitka (main)-299992395.6826923076923502.2160703486926Nuitka (develop)-299992549.0480769230769502.2160703486926Nuitka (factory)Construct CallLambdaExpressionDirectlyTicks Construct CallLambdaExpressionDirectly 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)5131060688.95192307692307255.5632541975567CPython 3.8-300068242.31730769230768502.67863881294136Nuitka (main)-300068395.6826923076923502.67863881294136Nuitka (develop)-300068549.0480769230769502.67863881294136Nuitka (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_574687fc8c69919ab6b3934a7c9e2328; 82 static PyCodeObject *codeobj_574687fc8c69919ab6b3934a7c9e2328;
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_7082d63f6926e0f60f0503d0bceae308 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0); 88     codeobj_7082d63f6926e0f60f0503d0bceae308 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], NULL, NULL, 0, 0, 0);
89     codeobj_574687fc8c69919ab6b3934a7c9e2328 = MAKE_CODEOBJECT(module_filename_obj, 22, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[7], NULL, NULL, 0, 0, 0); 89     codeobj_574687fc8c69919ab6b3934a7c9e2328 = 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_574687fc8c69919ab6b3934a7c9e2328, 105         codeobj_574687fc8c69919ab6b3934a7c9e2328,
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",
556 481
557     // Module code. 482     // Module code.
558     { 483     {
559         PyObject *tmp_assign_source_1; 484         PyObject *tmp_assign_source_1;
560         tmp_assign_source_1 = Py_None; 485         tmp_assign_source_1 = Py_None;
n 561         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);
562     } 487     }
563     { 488     {
564         PyObject *tmp_assign_source_2; 489         PyObject *tmp_assign_source_2;
n 565         tmp_assign_source_2 = mod_consts[2]; n 490         tmp_assign_source_2 = mod_consts[1];
566         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);
567     } 492     }
568     { 493     {
569         PyObject *tmp_assign_source_3; 494         PyObject *tmp_assign_source_3;
570         tmp_assign_source_3 = Py_None; 495         tmp_assign_source_3 = Py_None;
n 571         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); n 496         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
572     } 497     }
573     { 498     {
574         PyObject *tmp_assign_source_4; 499         PyObject *tmp_assign_source_4;
575         tmp_assign_source_4 = PyDict_New(); 500         tmp_assign_source_4 = PyDict_New();
n 576         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4); n 501         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_4);
577     } 502     }
578     { 503     {
579         PyObject *tmp_assign_source_5; 504         PyObject *tmp_assign_source_5;
580         { 505         {
581             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 506             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 582             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[6]); n 507             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[5]);
583         } 508         }
584 509
585         assert(!(tmp_assign_source_5 == NULL)); 510         assert(!(tmp_assign_source_5 == NULL));
t 586         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5); t 511         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_5);
587     } 512     }
588     { 513     {
589         PyObject *tmp_assign_source_6; 514         PyObject *tmp_assign_source_6;
590 515
591 516