Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1651980388.95192307692307257.0CPython 2.78150922242.31730769230768382.1878879618228Nuitka (master)8150363395.6826923076923382.1962498956788Nuitka (develop)8150381549.0480769230769382.1959806384169Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2542653688.95192307692307257.0CPython 3.511397473242.31730769230768393.34563902210124Nuitka (master)11407587395.6826923076923393.2473430922113Nuitka (develop)11398675549.0480769230769393.33395702608306Nuitka (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
33 /* The module constants used, if any. */ 33 /* The module constants used, if any. */
34 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
35 static PyObject *const_str_plain___package__; 35 static PyObject *const_str_plain___package__;
36 static PyObject *const_str_plain___spec__; 36 static PyObject *const_str_plain___spec__;
37 static PyObject *const_tuple_str_plain_empty_tuple; 37 static PyObject *const_tuple_str_plain_empty_tuple;
n n 38 extern PyObject *const_int_pos_1;
38 extern PyObject *const_dict_empty; 39 extern PyObject *const_dict_empty;
39 extern PyObject *const_str_plain___file__; 40 extern PyObject *const_str_plain___file__;
40 extern PyObject *const_int_0; 41 extern PyObject *const_int_0;
41 static PyObject *const_str_plain_empty; 42 static PyObject *const_str_plain_empty;
42 extern PyObject *const_str_plain_print; 43 extern PyObject *const_str_plain_print;
n 43 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
44 static PyObject *const_int_pos_50000; 44 static PyObject *const_int_pos_50000;
45 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 45 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
46 static PyObject *const_str_plain_calledRepeatedly; 46 static PyObject *const_str_plain_calledRepeatedly;
47 static PyObject *const_str_angle_module; 47 static PyObject *const_str_angle_module;
48 static PyObject *const_str_plain_x; 48 static PyObject *const_str_plain_x;
65     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 9 ], 11, 1 ); 65     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 9 ], 11, 1 );
66     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 20 ], 8, 1 ); 66     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 20 ], 8, 1 );
67     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 67     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
68     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 28 ], 5, 1 ); 68     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 28 ], 5, 1 );
69     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 69     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
n 70     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 33 ], 31, 0 ); n
71     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 70     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
72     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 71     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 73     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 64 ], 3, 0 ); n 72     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 33 ], 3, 0 );
74     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 73     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 75     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 33 ], 16, 1 ); n 74     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 36 ], 16, 1 );
76     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 67 ], 8, 0 ); 75     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 52 ], 8, 0 );
77     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 75 ], 1, 1 ); 76     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 60 ], 1, 1 );
78     const_str_digest_1970e8d01db464ccef679d057103d3d8 = UNSTREAM_STRING( &constant_bin[ 76 ], 79, 0 ); 77     const_str_digest_1970e8d01db464ccef679d057103d3d8 = UNSTREAM_STRING( &constant_bin[ 61 ], 79, 0 );
79     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 155 ], 6, 1 ); 78     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 140 ], 6, 1 );
80     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 79     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
81     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, 0, Py_None ); Py_INCREF( Py_None );
82     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 81     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
83 82
84     constants_created = true; 83     constants_created = true;
95 #endif 94 #endif
96 95
97 // The module code objects. 96 // The module code objects.
98 static PyCodeObject *codeobj_4708a2531559a67c423818fab8f4c409; 97 static PyCodeObject *codeobj_4708a2531559a67c423818fab8f4c409;
99 static PyCodeObject *codeobj_8d89a859aaa8e561fb2071b9b738b87f; 98 static PyCodeObject *codeobj_8d89a859aaa8e561fb2071b9b738b87f;
n 100 static PyCodeObject *codeobj_3fd69da6ea019b9f4ac1d44f831518d5; n
101 /* For use in "MainProgram.c". */ 99 /* For use in "MainProgram.c". */
102 PyCodeObject *codeobj_main = NULL; 100 PyCodeObject *codeobj_main = NULL;
103 101
104 static void createModuleCodeObjects(void) 102 static void createModuleCodeObjects(void)
105 { 103 {
106     module_filename_obj = const_str_digest_1970e8d01db464ccef679d057103d3d8; 104     module_filename_obj = const_str_digest_1970e8d01db464ccef679d057103d3d8;
107     codeobj_4708a2531559a67c423818fab8f4c409 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 105     codeobj_4708a2531559a67c423818fab8f4c409 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
108     codeobj_main = codeobj_4708a2531559a67c423818fab8f4c409; 106     codeobj_main = codeobj_4708a2531559a67c423818fab8f4c409;
109     codeobj_8d89a859aaa8e561fb2071b9b738b87f = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 107     codeobj_8d89a859aaa8e561fb2071b9b738b87f = 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 110     codeobj_3fd69da6ea019b9f4ac1d44f831518d5 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
111 } 108 }
112 109
113 // The module function declarations. 110 // The module function declarations.
114 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 111 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 115   n
116  
117 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
118 112
119 113
120 // The module function definitions. 114 // The module function definitions.
121 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 115 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
122 { 116 {
124 #ifndef __NUITKA_NO_ASSERT__ 118 #ifndef __NUITKA_NO_ASSERT__
125     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 119     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
126 #endif 120 #endif
127 121
128     // Local variable declarations. 122     // Local variable declarations.
n 129     PyObject *var_empty = NULL; n
130     PyObject *tmp_assign_source_1;
131     PyObject *tmp_return_value; 123     PyObject *tmp_return_value;
132     tmp_return_value = NULL; 124     tmp_return_value = NULL;
133 125
134     // Actual function code. 126     // Actual function code.
n 135     tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  ); n 127     tmp_return_value = const_int_pos_1;
136     assert( var_empty == NULL );
137     var_empty = tmp_assign_source_1;
138  
139     // Tried code:
140     tmp_return_value = var_empty;
141  
142     CHECK_OBJECT( tmp_return_value );
143     Py_INCREF( tmp_return_value ); 128     Py_INCREF( tmp_return_value );
n 144     goto try_return_handler_1; n
145     // tried codes exits in all cases
146     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
147     return NULL;
148     // Return handler code:
149     try_return_handler_1:;
150     CHECK_OBJECT( (PyObject *)var_empty );
151     Py_DECREF( var_empty );
152     var_empty = NULL;
153  
154     goto function_return_exit; 129     goto function_return_exit;
n 155     // End of try: n
156 130
157     // Return statement must have exited already. 131     // Return statement must have exited already.
158     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 132     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 159     return NULL; n
160  
161     function_return_exit:
162  
163     CHECK_OBJECT( tmp_return_value );
164     assert( had_error || !ERROR_OCCURRED() );
165     return tmp_return_value;
166  
167 }
168  
169  
170 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
171 {
172     // Preserve error status for checks
173 #ifndef __NUITKA_NO_ASSERT__
174     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
175 #endif
176  
177     // Local variable declarations.
178     PyObject *tmp_return_value;
179     tmp_return_value = NULL;
180  
181     // Actual function code.
182     tmp_return_value = Py_None;
183     Py_INCREF( tmp_return_value );
184     goto function_return_exit;
185  
186     // Return statement must have exited already.
187     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
188     return NULL; 133     return NULL;
189 134
190     function_return_exit: 135     function_return_exit:
191 136
192     CHECK_OBJECT( tmp_return_value ); 137     CHECK_OBJECT( tmp_return_value );
204         const_str_plain_calledRepeatedly, 149         const_str_plain_calledRepeatedly,
205 #if PYTHON_VERSION >= 330 150 #if PYTHON_VERSION >= 330
206         NULL, 151         NULL,
207 #endif 152 #endif
208         codeobj_8d89a859aaa8e561fb2071b9b738b87f, 153         codeobj_8d89a859aaa8e561fb2071b9b738b87f,
t 209         NULL, t
210 #if PYTHON_VERSION >= 300
211         NULL,
212         const_dict_empty,
213 #endif
214         module___main__,
215         Py_None,
216         0
217     );
218  
219  
220     return (PyObject *)result;
221 }
222  
223  
224  
225 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
226 {
227     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
228         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
229         const_str_plain_empty,
230 #if PYTHON_VERSION >= 330
231         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
232 #endif
233         codeobj_3fd69da6ea019b9f4ac1d44f831518d5,
234         NULL, 154         NULL,
235 #if PYTHON_VERSION >= 300 155 #if PYTHON_VERSION >= 300
236         NULL, 156         NULL,
237         const_dict_empty, 157         const_dict_empty,
238 #endif 158 #endif