Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1957522188.95192307692307257.0CPython 2.78250345242.31730769230768399.96395879574175Nuitka (master)8250339395.6826923076923399.96403453906584Nuitka (develop)8250303549.0480769230769399.9644889990102Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2587527288.95192307692307257.0CPython 3.510207219242.31730769230768406.633864458284Nuitka (master)10206214395.6826923076923406.6434624621828Nuitka (develop)10205272549.0480769230769406.65245880016556Nuitka (factory)Construct FunctionCreationLocalTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin
    def empty():
        pass
# construct_alternative



    return empty


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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin


# construct_alternative
    empty = 1
# construct_end

    return empty


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

print("OK.")

Context Diff of Source Code


Construct
Baseline
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25 # construct_begin 25 # construct_begin
n 26     def empty(): n
27         pass
28 # construct_alternative
29 26
30 27
t t 28 # construct_alternative
29     empty = 1
30 # construct_end
31 31
32     return empty 32     return empty
33 33
34 34
35 import itertools 35 import itertools

Context Diff of Generated Code


Construct
Baseline
32 32
33 /* The declarations of module constants used, if any. */ 33 /* The declarations of module constants used, if any. */
34 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
35 static PyObject *const_tuple_str_plain_empty_tuple; 35 static PyObject *const_tuple_str_plain_empty_tuple;
36 static PyObject *const_str_digest_a8ea6ec80e5e35972745027142e7adb8; 36 static PyObject *const_str_digest_a8ea6ec80e5e35972745027142e7adb8;
n n 37 extern PyObject *const_int_pos_1;
37 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
38 extern PyObject *const_int_0; 39 extern PyObject *const_int_0;
39 static PyObject *const_str_plain_empty; 40 static PyObject *const_str_plain_empty;
n 40 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
41 extern PyObject *const_str_plain_print; 41 extern PyObject *const_str_plain_print;
42 static PyObject *const_int_pos_50000; 42 static PyObject *const_int_pos_50000;
43 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 43 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
44 static PyObject *const_str_plain_calledRepeatedly; 44 static PyObject *const_str_plain_calledRepeatedly;
45 static PyObject *const_str_angle_module; 45 static PyObject *const_str_angle_module;
63     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 ); 63     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 );
64     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 64     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
65     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 5, 1 ); 65     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 5, 1 );
66     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 66     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
67     const_str_digest_a8ea6ec80e5e35972745027142e7adb8 = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 72, 0 ); 67     const_str_digest_a8ea6ec80e5e35972745027142e7adb8 = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 72, 0 );
n 68     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII( &constant_bin[ 86 ], 31, 0 ); n
69     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 68     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
70     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 69     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 71     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 117 ], 3, 0 ); n 70     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 86 ], 3, 0 );
72     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 71     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 86 ], 16, 1 ); n 72     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 89 ], 16, 1 );
74     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 120 ], 8, 0 ); 73     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 105 ], 8, 0 );
75     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 128 ], 4, 1 ); 74     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 113 ], 4, 1 );
76     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 39 ], 1, 1 ); 75     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 39 ], 1, 1 );
n 77     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 132 ], 6, 1 ); n 76     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 117 ], 6, 1 );
78     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 77     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
79     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 78     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
80     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 79     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
81 80
82     constants_created = true; 81     constants_created = true;
94 #endif 93 #endif
95 94
96 // The module code objects. 95 // The module code objects.
97 static PyCodeObject *codeobj_f0e6ee744b12a02bf453041e3cd50804; 96 static PyCodeObject *codeobj_f0e6ee744b12a02bf453041e3cd50804;
98 static PyCodeObject *codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa; 97 static PyCodeObject *codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa;
n 99 static PyCodeObject *codeobj_92d30988cf5830b3a4a005a88f474278; n
100 /* For use in "MainProgram.c". */ 98 /* For use in "MainProgram.c". */
101 PyCodeObject *codeobj_main = NULL; 99 PyCodeObject *codeobj_main = NULL;
102 100
103 static void createModuleCodeObjects(void) 101 static void createModuleCodeObjects(void)
104 { 102 {
105     module_filename_obj = const_str_digest_a8ea6ec80e5e35972745027142e7adb8; 103     module_filename_obj = const_str_digest_a8ea6ec80e5e35972745027142e7adb8;
106     codeobj_f0e6ee744b12a02bf453041e3cd50804 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 104     codeobj_f0e6ee744b12a02bf453041e3cd50804 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
107     codeobj_main = codeobj_f0e6ee744b12a02bf453041e3cd50804; 105     codeobj_main = codeobj_f0e6ee744b12a02bf453041e3cd50804;
108     codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 106     codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
n 109     codeobj_92d30988cf5830b3a4a005a88f474278 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
110 } 107 }
111 108
112 // The module function declarations. 109 // The module function declarations.
113 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 110 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 114   n
115  
116 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
117 111
118 112
119 // The module function definitions. 113 // The module function definitions.
120 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 114 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
121 { 115 {
123 #ifndef __NUITKA_NO_ASSERT__ 117 #ifndef __NUITKA_NO_ASSERT__
124     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 118     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
125 #endif 119 #endif
126 120
127     // Local variable declarations. 121     // Local variable declarations.
n 128     PyObject *var_empty = NULL; n
129     PyObject *tmp_return_value = NULL; 122     PyObject *tmp_return_value = NULL;
130 123
131     // Actual function body. 124     // Actual function body.
n 132     { n 125     tmp_return_value = const_int_pos_1;
133         PyObject *tmp_assign_source_1;
134         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
135  
136  
137  
138         assert( var_empty == NULL );
139         var_empty = tmp_assign_source_1;
140     }
141     // Tried code:
142     CHECK_OBJECT( var_empty );
143     tmp_return_value = var_empty;
144     Py_INCREF( tmp_return_value ); 126     Py_INCREF( tmp_return_value );
n 145     goto try_return_handler_1; n
146     // tried codes exits in all cases
147     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
148     return NULL;
149     // Return handler code:
150     try_return_handler_1:;
151     CHECK_OBJECT( (PyObject *)var_empty );
152     Py_DECREF( var_empty );
153     var_empty = NULL;
154  
155     goto function_return_exit; 127     goto function_return_exit;
n 156     // End of try: n
157 128
158     // Return statement must have exited already. 129     // Return statement must have exited already.
159     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 130     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 160     return NULL; n
161  
162  
163 function_return_exit:
164    // Function cleanup code if any.
165  
166  
167    // Actual function exit with return value, making sure we did not make
168    // the error status worse despite non-NULL return.
169    CHECK_OBJECT( tmp_return_value );
170    assert( had_error || !ERROR_OCCURRED() );
171    return tmp_return_value;
172 }
173  
174  
175 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
176 {
177     // Preserve error status for checks
178 #ifndef __NUITKA_NO_ASSERT__
179     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
180 #endif
181  
182     // Local variable declarations.
183     PyObject *tmp_return_value = NULL;
184  
185     // Actual function body.
186     tmp_return_value = Py_None;
187     Py_INCREF( tmp_return_value );
188     goto function_return_exit;
189  
190     // Return statement must have exited already.
191     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
192     return NULL; 131     return NULL;
193 132
194 133
195 function_return_exit: 134 function_return_exit:
196    // Function cleanup code if any. 135    // Function cleanup code if any.
212         const_str_plain_calledRepeatedly, 151         const_str_plain_calledRepeatedly,
213 #if PYTHON_VERSION >= 300 152 #if PYTHON_VERSION >= 300
214         NULL, 153         NULL,
215 #endif 154 #endif
216         codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa, 155         codeobj_f7e76fe4cf0fbd7ffee57d2d13b6cbfa,
t 217         NULL, t
218 #if PYTHON_VERSION >= 300
219         NULL,
220         NULL,
221 #endif
222         module___main__,
223         NULL,
224         0
225     );
226  
227     return (PyObject *)result;
228 }
229  
230  
231  
232 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
233 {
234     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
235         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
236         const_str_plain_empty,
237 #if PYTHON_VERSION >= 300
238         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
239 #endif
240         codeobj_92d30988cf5830b3a4a005a88f474278,
241         NULL, 156         NULL,
242 #if PYTHON_VERSION >= 300 157 #if PYTHON_VERSION >= 300
243         NULL, 158         NULL,
244         NULL, 159         NULL,
245 #endif 160 #endif