Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1982529688.95192307692307257.0CPython 2.78550485242.31730769230768397.5365779522671Nuitka (master)8200317395.6826923076923401.9012996694107Nuitka (develop)8200419549.0480769230769401.9000282750653Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2552502888.95192307692307257.0CPython 3.510750207242.31730769230768400.03943463013877Nuitka (master)10200100395.6826923076923405.36518404301364Nuitka (develop)10201290549.0480769230769405.3536632992287Nuitka (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 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_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_digest_b87433cf58d682fd1137d363fe0a9fee; 43 static PyObject *const_str_digest_b87433cf58d682fd1137d363fe0a9fee;
44 static PyObject *const_str_plain_calledRepeatedly; 44 static PyObject *const_str_plain_calledRepeatedly;
60 { 60 {
61     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 ); 61     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 );
62     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 62     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
63     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 9 ], 5, 1 ); 63     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 9 ], 5, 1 );
64     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 64     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
n 65     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 14 ], 31, 0 ); n
66     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 65     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
67     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 66     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 68     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 45 ], 3, 0 ); n 67     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 14 ], 3, 0 );
69     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 68     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 70     const_str_digest_b87433cf58d682fd1137d363fe0a9fee = UNSTREAM_STRING( &constant_bin[ 48 ], 79, 0 ); n 69     const_str_digest_b87433cf58d682fd1137d363fe0a9fee = UNSTREAM_STRING( &constant_bin[ 17 ], 79, 0 );
71     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 14 ], 16, 1 ); 70     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 96 ], 16, 1 );
72     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 127 ], 8, 0 ); 71     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 112 ], 8, 0 );
73     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 135 ], 4, 1 ); 72     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 120 ], 4, 1 );
74     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 73 ], 1, 1 ); 73     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 42 ], 1, 1 );
75     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 139 ], 6, 1 ); 74     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 124 ], 6, 1 );
76     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 75     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
77     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 76     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, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 77     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
79 78
80     constants_created = true; 79     constants_created = true;
91 #endif 90 #endif
92 91
93 // The module code objects. 92 // The module code objects.
94 static PyCodeObject *codeobj_9a2338e5d03b5d568ae5e3c2a1482c94; 93 static PyCodeObject *codeobj_9a2338e5d03b5d568ae5e3c2a1482c94;
95 static PyCodeObject *codeobj_9eed0a3a278452b31063de44c67ad135; 94 static PyCodeObject *codeobj_9eed0a3a278452b31063de44c67ad135;
n 96 static PyCodeObject *codeobj_ea432222c2cba7f64f435f04bc28f791; n
97 /* For use in "MainProgram.c". */ 95 /* For use in "MainProgram.c". */
98 PyCodeObject *codeobj_main = NULL; 96 PyCodeObject *codeobj_main = NULL;
99 97
100 static void createModuleCodeObjects(void) 98 static void createModuleCodeObjects(void)
101 { 99 {
102     module_filename_obj = const_str_digest_b87433cf58d682fd1137d363fe0a9fee; 100     module_filename_obj = const_str_digest_b87433cf58d682fd1137d363fe0a9fee;
103     codeobj_9a2338e5d03b5d568ae5e3c2a1482c94 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 101     codeobj_9a2338e5d03b5d568ae5e3c2a1482c94 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
104     codeobj_main = codeobj_9a2338e5d03b5d568ae5e3c2a1482c94; 102     codeobj_main = codeobj_9a2338e5d03b5d568ae5e3c2a1482c94;
105     codeobj_9eed0a3a278452b31063de44c67ad135 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 103     codeobj_9eed0a3a278452b31063de44c67ad135 = 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 106     codeobj_ea432222c2cba7f64f435f04bc28f791 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
107 } 104 }
108 105
109 // The module function declarations. 106 // The module function declarations.
110 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 107 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 111   n
112  
113 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
114 108
115 109
116 // The module function definitions. 110 // The module function definitions.
117 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 111 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
118 { 112 {
120 #ifndef __NUITKA_NO_ASSERT__ 114 #ifndef __NUITKA_NO_ASSERT__
121     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
122 #endif 116 #endif
123 117
124     // Local variable declarations. 118     // Local variable declarations.
n 125     PyObject *var_empty = NULL; n
126     PyObject *tmp_return_value = NULL; 119     PyObject *tmp_return_value = NULL;
127 120
128     // Actual function code. 121     // Actual function code.
129     { 122     {
n 130     PyObject *tmp_assign_source_1; n 123     tmp_return_value = const_int_pos_1;
131     tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
132  
133  
134  
135     assert( var_empty == NULL );
136     var_empty = tmp_assign_source_1;
137  
138     }
139     {
140     // Tried code:
141     {
142     tmp_return_value = var_empty;
143  
144     CHECK_OBJECT( tmp_return_value );
145     Py_INCREF( tmp_return_value ); 124     Py_INCREF( tmp_return_value );
n 146     goto try_return_handler_1; n
147     }
148     // tried codes exits in all cases
149     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
150     return NULL;
151     // Return handler code:
152     try_return_handler_1:;
153     {
154     CHECK_OBJECT( (PyObject *)var_empty );
155     Py_DECREF( var_empty );
156     var_empty = NULL;
157  
158     }
159     {
160     goto function_return_exit; 125     goto function_return_exit;
n 161     } n
162     // End of try:
163     } 126     }
164 127
165     // Return statement must have exited already. 128     // Return statement must have exited already.
166     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 129     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 167     return NULL; n
168  
169 function_return_exit:
170  
171 CHECK_OBJECT( tmp_return_value );
172 assert( had_error || !ERROR_OCCURRED() );
173 return tmp_return_value;
174  
175 }
176  
177  
178 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
179 {
180     // Preserve error status for checks
181 #ifndef __NUITKA_NO_ASSERT__
182     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
183 #endif
184  
185     // Local variable declarations.
186     PyObject *tmp_return_value = NULL;
187  
188     // Actual function code.
189     {
190     tmp_return_value = Py_None;
191     Py_INCREF( tmp_return_value );
192     goto function_return_exit;
193     }
194  
195     // Return statement must have exited already.
196     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
197     return NULL; 130     return NULL;
198 131
199 function_return_exit: 132 function_return_exit:
200 133
201 CHECK_OBJECT( tmp_return_value ); 134 CHECK_OBJECT( tmp_return_value );
213         const_str_plain_calledRepeatedly, 146         const_str_plain_calledRepeatedly,
214 #if PYTHON_VERSION >= 300 147 #if PYTHON_VERSION >= 300
215         NULL, 148         NULL,
216 #endif 149 #endif
217         codeobj_9eed0a3a278452b31063de44c67ad135, 150         codeobj_9eed0a3a278452b31063de44c67ad135,
t 218         NULL, t
219 #if PYTHON_VERSION >= 300
220         NULL,
221         NULL,
222 #endif
223         module___main__,
224         NULL,
225         0
226     );
227  
228     return (PyObject *)result;
229 }
230  
231  
232  
233 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
234 {
235     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
236         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
237         const_str_plain_empty,
238 #if PYTHON_VERSION >= 300
239         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
240 #endif
241         codeobj_ea432222c2cba7f64f435f04bc28f791,
242         NULL, 151         NULL,
243 #if PYTHON_VERSION >= 300 152 #if PYTHON_VERSION >= 300
244         NULL, 153         NULL,
245         NULL, 154         NULL,
246 #endif 155 #endif