Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)1651931873.61538461538461257.0CPython 2.711200275196.30769230769232336.56850014817616Nuitka (historic)8150183319.0000000000001382.1953630545206Nuitka (master)8149871441.69230769230774382.2000303174185Nuitka (develop)8149871564.3846153846155382.2000303174185Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)2542751173.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)11409534319.0000000000001393.2326724737083Nuitka (master)11398873441.69230769230774393.3362806135449Nuitka (develop)11409220564.3846153846155393.2357240594797Nuitka (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


for x in xrange(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


for x in xrange(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 for x in xrange(50000): 35 for x in xrange(50000):

Context Diff of Generated Code


Construct
Baseline
29 29
30 PyObject *module___main__; 30 PyObject *module___main__;
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
32 32
33 /* The module constants used, if any. */ 33 /* The module constants used, if any. */
n n 34 extern PyObject *const_str_plain___file__;
35 static PyObject *const_str_plain_calledRepeatedly;
36 extern PyObject *const_str_plain___main__;
34 static PyObject *const_str_plain___package__; 37 static PyObject *const_str_plain___package__;
n n 38 extern PyObject *const_int_0;
39 static PyObject *const_str_angle_module;
35 static PyObject *const_tuple_str_plain_empty_tuple; 40 static PyObject *const_tuple_str_plain_empty_tuple;
n 36 extern PyObject *const_int_pos_1; n
37 extern PyObject *const_dict_empty;
38 extern PyObject *const_str_plain___file__;
39 extern PyObject *const_int_0;
40 static PyObject *const_xrange_0_50000; 41 static PyObject *const_xrange_0_50000;
n n 42 static PyObject *const_str_plain_x;
41 static PyObject *const_str_plain_empty; 43 static PyObject *const_str_plain_empty;
42 extern PyObject *const_str_plain_print; 44 extern PyObject *const_str_plain_print;
n 43 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n 45 extern PyObject *const_int_pos_1;
46 extern PyObject *const_str_plain___doc__;
47 extern PyObject *const_str_plain___cached__;
48 extern PyObject *const_tuple_empty;
44 static PyObject *const_int_pos_50000; 49 static PyObject *const_int_pos_50000;
45 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 50 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
n n 51 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
52 extern PyObject *const_dict_empty;
46 static PyObject *const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7; 53 static PyObject *const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7;
n 47 static PyObject *const_str_plain_calledRepeatedly; n
48 static PyObject *const_str_angle_module;
49 static PyObject *const_str_plain_x;
50 extern PyObject *const_tuple_empty;
51 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
52 extern PyObject *const_str_plain___main__;
53 extern PyObject *const_str_plain___doc__;
54 extern PyObject *const_str_plain___cached__;
55 static PyObject *module_filename_obj; 54 static PyObject *module_filename_obj;
56 55
57 static bool constants_created = false; 56 static bool constants_created = false;
58 57
59 static void createModuleConstants( void ) 58 static void createModuleConstants( void )
60 { 59 {
n n 60     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
61     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 ); 61     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 16 ], 11, 1 );
62     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 27 ], 8, 0 );
62     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 63     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
n 63     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 11 ], 5, 1 ); n 64     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 35 ], 5, 1 );
64     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 65     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
65     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 66     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
66     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 67     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
n 67     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 16 ], 31, 0 ); n 68     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 40 ], 1, 1 );
68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 69     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 47 ], 3, 0 ); n 70     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 41 ], 3, 0 );
70     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 71     const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7 = UNSTREAM_STRING( &constant_bin[ 50 ], 79, 0 ); n 72     const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7 = UNSTREAM_STRING( &constant_bin[ 44 ], 79, 0 );
72     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 16 ], 16, 1 );
73     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 129 ], 8, 0 );
74     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 75 ], 1, 1 );
75 73
76     constants_created = true; 74     constants_created = true;
77 } 75 }
78 76
79 #ifndef __NUITKA_NO_ASSERT__ 77 #ifndef __NUITKA_NO_ASSERT__
87 #endif 85 #endif
88 86
89 // The module code objects. 87 // The module code objects.
90 static PyCodeObject *codeobj_f6604943e8814623eee71931b9b26e8d; 88 static PyCodeObject *codeobj_f6604943e8814623eee71931b9b26e8d;
91 static PyCodeObject *codeobj_27004db121d4ce892e318d8b136bcfff; 89 static PyCodeObject *codeobj_27004db121d4ce892e318d8b136bcfff;
n 92 static PyCodeObject *codeobj_ba5f8e011584e5ec35453fd8616405b6; n
93 /* For use in "MainProgram.c". */ 90 /* For use in "MainProgram.c". */
94 PyCodeObject *codeobj_main = NULL; 91 PyCodeObject *codeobj_main = NULL;
95 92
96 static void createModuleCodeObjects(void) 93 static void createModuleCodeObjects(void)
97 { 94 {
98     module_filename_obj = const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7; 95     module_filename_obj = const_str_digest_48ecc0e40f1dad6c71df7539c150ccc7;
99     codeobj_f6604943e8814623eee71931b9b26e8d = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 96     codeobj_f6604943e8814623eee71931b9b26e8d = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
100     codeobj_main = codeobj_f6604943e8814623eee71931b9b26e8d; 97     codeobj_main = codeobj_f6604943e8814623eee71931b9b26e8d;
101     codeobj_27004db121d4ce892e318d8b136bcfff = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 98     codeobj_27004db121d4ce892e318d8b136bcfff = 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 102     codeobj_ba5f8e011584e5ec35453fd8616405b6 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
103 } 99 }
104 100
105 // The module function declarations. 101 // The module function declarations.
106 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 102 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 107   n
108  
109 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
110 103
111 104
112 // The module function definitions. 105 // The module function definitions.
113 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 106 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
114 { 107 {
116 #ifndef __NUITKA_NO_ASSERT__ 109 #ifndef __NUITKA_NO_ASSERT__
117     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 110     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
118 #endif 111 #endif
119 112
120     // Local variable declarations. 113     // Local variable declarations.
n 121     PyObject *var_empty = NULL; n
122     PyObject *tmp_assign_source_1;
123     PyObject *tmp_return_value; 114     PyObject *tmp_return_value;
124     tmp_return_value = NULL; 115     tmp_return_value = NULL;
125 116
126     // Actual function code. 117     // Actual function code.
n 127     tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  ); n 118     tmp_return_value = const_int_pos_1;
128     assert( var_empty == NULL );
129     var_empty = tmp_assign_source_1;
130  
131     // Tried code:
132     tmp_return_value = var_empty;
133  
134     CHECK_OBJECT( tmp_return_value );
135     Py_INCREF( tmp_return_value ); 119     Py_INCREF( tmp_return_value );
n 136     goto try_return_handler_1; n
137     // tried codes exits in all cases
138     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
139     return NULL;
140     // Return handler code:
141     try_return_handler_1:;
142     CHECK_OBJECT( (PyObject *)var_empty );
143     Py_DECREF( var_empty );
144     var_empty = NULL;
145  
146     goto function_return_exit; 120     goto function_return_exit;
n 147     // End of try: n
148 121
149     // Return statement must have exited already. 122     // Return statement must have exited already.
150     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 123     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 151     return NULL; n
152  
153     function_return_exit:
154  
155     CHECK_OBJECT( tmp_return_value );
156     assert( had_error || !ERROR_OCCURRED() );
157     return tmp_return_value;
158  
159 }
160  
161  
162 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
163 {
164     // Preserve error status for checks
165 #ifndef __NUITKA_NO_ASSERT__
166     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
167 #endif
168  
169     // Local variable declarations.
170     PyObject *tmp_return_value;
171     tmp_return_value = NULL;
172  
173     // Actual function code.
174     tmp_return_value = Py_None;
175     Py_INCREF( tmp_return_value );
176     goto function_return_exit;
177  
178     // Return statement must have exited already.
179     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
180     return NULL; 124     return NULL;
181 125
182     function_return_exit: 126     function_return_exit:
183 127
184     CHECK_OBJECT( tmp_return_value ); 128     CHECK_OBJECT( tmp_return_value );
196         const_str_plain_calledRepeatedly, 140         const_str_plain_calledRepeatedly,
197 #if PYTHON_VERSION >= 330 141 #if PYTHON_VERSION >= 330
198         NULL, 142         NULL,
199 #endif 143 #endif
200         codeobj_27004db121d4ce892e318d8b136bcfff, 144         codeobj_27004db121d4ce892e318d8b136bcfff,
t 201         NULL, t
202 #if PYTHON_VERSION >= 300
203         NULL,
204         const_dict_empty,
205 #endif
206         module___main__,
207         Py_None,
208         0
209     );
210  
211  
212     return (PyObject *)result;
213 }
214  
215  
216  
217 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
218 {
219     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
220         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
221         const_str_plain_empty,
222 #if PYTHON_VERSION >= 330
223         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
224 #endif
225         codeobj_ba5f8e011584e5ec35453fd8616405b6,
226         NULL, 145         NULL,
227 #if PYTHON_VERSION >= 300 146 #if PYTHON_VERSION >= 300
228         NULL, 147         NULL,
229         const_dict_empty, 148         const_dict_empty,
230 #endif 149 #endif