Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1957522188.95192307692307257.0CPython 2.78250928242.31730769230768399.9565990694209Nuitka (master)8249716395.6826923076923399.97189922088046Nuitka (develop)8249578549.0480769230769399.9736413173338Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2587527288.95192307692307257.0CPython 3.510200593242.31730769230768406.6971444322476Nuitka (master)10200315395.6826923076923406.6997994024803Nuitka (develop)10201853549.0480769230769406.6851111139267Nuitka (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
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
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;
n n 36 extern PyObject *const_int_pos_1;
36 extern PyObject *const_str_plain___file__; 37 extern PyObject *const_str_plain___file__;
37 extern PyObject *const_int_0; 38 extern PyObject *const_int_0;
38 static PyObject *const_str_plain_empty; 39 static PyObject *const_str_plain_empty;
n 39 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
40 extern PyObject *const_str_plain_print; 40 extern PyObject *const_str_plain_print;
41 static PyObject *const_int_pos_50000; 41 static PyObject *const_int_pos_50000;
42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
43 static PyObject *const_str_plain_calledRepeatedly; 43 static PyObject *const_str_plain_calledRepeatedly;
44 static PyObject *const_str_angle_module; 44 static PyObject *const_str_angle_module;
62 { 62 {
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 );
n 67     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 31, 0 ); n
68     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 67     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
69     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 70     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 45 ], 3, 0 ); n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 3, 0 );
71     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 70     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 72     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 16, 1 ); n 71     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 17 ], 16, 1 );
73     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 48 ], 8, 0 ); 72     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 33 ], 8, 0 );
74     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 56 ], 4, 1 ); 73     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 41 ], 4, 1 );
75     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 60 ], 1, 1 ); 74     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 45 ], 1, 1 );
76     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 6, 1 ); 75     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 46 ], 6, 1 );
77     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 76     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
78     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 77     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
79     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 78     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 80     const_str_digest_ab7fe524a5e92c010e787ae249d1c1a2 = UNSTREAM_STRING_ASCII( &constant_bin[ 67 ], 72, 0 ); n 79     const_str_digest_ab7fe524a5e92c010e787ae249d1c1a2 = UNSTREAM_STRING_ASCII( &constant_bin[ 52 ], 72, 0 );
81 80
82     constants_created = true; 81     constants_created = true;
83 } 82 }
84 83
85 /* Function to verify module private constants for non-corruption. */ 84 /* Function to verify module private constants for non-corruption. */
94 #endif 93 #endif
95 94
96 // The module code objects. 95 // The module code objects.
97 static PyCodeObject *codeobj_72159c0768fa07697c0563a49b23c188; 96 static PyCodeObject *codeobj_72159c0768fa07697c0563a49b23c188;
98 static PyCodeObject *codeobj_b1b90ef8810f03ecb9d1d24637818cea; 97 static PyCodeObject *codeobj_b1b90ef8810f03ecb9d1d24637818cea;
n 99 static PyCodeObject *codeobj_ee7403ba82a5f5be38f74f28b4ed40d1; 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_ab7fe524a5e92c010e787ae249d1c1a2; 103     module_filename_obj = const_str_digest_ab7fe524a5e92c010e787ae249d1c1a2;
106     codeobj_72159c0768fa07697c0563a49b23c188 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 104     codeobj_72159c0768fa07697c0563a49b23c188 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
107     codeobj_b1b90ef8810f03ecb9d1d24637818cea = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 105     codeobj_b1b90ef8810f03ecb9d1d24637818cea = 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 108     codeobj_ee7403ba82a5f5be38f74f28b4ed40d1 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
109 } 106 }
110 107
111 // The module function declarations. 108 // The module function declarations.
112 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 109 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 113   n
114  
115 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
116 110
117 111
118 // The module function definitions. 112 // The module function definitions.
119 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 113 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
120 { 114 {
122 #ifndef __NUITKA_NO_ASSERT__ 116 #ifndef __NUITKA_NO_ASSERT__
123     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 117     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
124 #endif 118 #endif
125 119
126     // Local variable declarations. 120     // Local variable declarations.
n 127     PyObject *var_empty = NULL; n
128     PyObject *tmp_return_value = NULL; 121     PyObject *tmp_return_value = NULL;
129 122
130     // Actual function body. 123     // Actual function body.
n 131     { n 124     tmp_return_value = const_int_pos_1;
132         PyObject *tmp_assign_source_1;
133         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
134  
135  
136  
137         assert( var_empty == NULL );
138         var_empty = tmp_assign_source_1;
139     }
140     // Tried code:
141     CHECK_OBJECT( var_empty );
142     tmp_return_value = var_empty;
143     Py_INCREF( tmp_return_value ); 125     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; 126     goto function_return_exit;
n 155     // End of try: n
156 127
157     // Return statement must have exited already. 128     // Return statement must have exited already.
158     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 129     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 159     return NULL; n
160  
161  
162 function_return_exit:
163    // Function cleanup code if any.
164  
165  
166    // Actual function exit with return value, making sure we did not make
167    // the error status worse despite non-NULL return.
168    CHECK_OBJECT( tmp_return_value );
169    assert( had_error || !ERROR_OCCURRED() );
170    return tmp_return_value;
171 }
172  
173  
174 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
175 {
176     // Preserve error status for checks
177 #ifndef __NUITKA_NO_ASSERT__
178     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
179 #endif
180  
181     // Local variable declarations.
182     PyObject *tmp_return_value = NULL;
183  
184     // Actual function body.
185     tmp_return_value = Py_None;
186     Py_INCREF( tmp_return_value );
187     goto function_return_exit;
188  
189     // Return statement must have exited already.
190     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
191     return NULL; 130     return NULL;
192 131
193 132
194 function_return_exit: 133 function_return_exit:
195    // Function cleanup code if any. 134    // Function cleanup code if any.
211         const_str_plain_calledRepeatedly, 150         const_str_plain_calledRepeatedly,
212 #if PYTHON_VERSION >= 300 151 #if PYTHON_VERSION >= 300
213         NULL, 152         NULL,
214 #endif 153 #endif
215         codeobj_b1b90ef8810f03ecb9d1d24637818cea, 154         codeobj_b1b90ef8810f03ecb9d1d24637818cea,
t 216         NULL, t
217 #if PYTHON_VERSION >= 300
218         NULL,
219         NULL,
220 #endif
221         module___main__,
222         NULL,
223         0
224     );
225  
226     return (PyObject *)result;
227 }
228  
229  
230  
231 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
232 {
233     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
234         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
235         const_str_plain_empty,
236 #if PYTHON_VERSION >= 300
237         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
238 #endif
239         codeobj_ee7403ba82a5f5be38f74f28b4ed40d1,
240         NULL, 155         NULL,
241 #if PYTHON_VERSION >= 300 156 #if PYTHON_VERSION >= 300
242         NULL, 157         NULL,
243         NULL, 158         NULL,
244 #endif 159 #endif