Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1982529688.95192307692307257.0CPython 2.78200652242.31730769230768401.89712401151155Nuitka (master)8200340395.6826923076923401.9010129824505Nuitka (develop)8200442549.0480769230769401.89974158810503Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2552502888.95192307692307257.0CPython 3.510200192242.31730769230768405.3642933636622Nuitka (master)10200792395.6826923076923405.35848458528324Nuitka (develop)10200688549.0480769230769405.35949144020225Nuitka (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_plain_calledRepeatedly; 43 static PyObject *const_str_plain_calledRepeatedly;
44 static PyObject *const_str_angle_module; 44 static PyObject *const_str_angle_module;
60 { 60 {
61     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 ); 61     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &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_ASCII( &constant_bin[ 9 ], 5, 1 ); 63     const_str_plain_empty = UNSTREAM_STRING_ASCII( &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_ASCII( &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_ASCII( &constant_bin[ 45 ], 3, 0 ); n 67     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &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_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 14 ], 16, 1 ); n 69     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 17 ], 16, 1 );
71     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 48 ], 8, 0 ); 70     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 33 ], 8, 0 );
72     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 56 ], 4, 1 ); 71     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 41 ], 4, 1 );
73     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 60 ], 1, 1 ); 72     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 45 ], 1, 1 );
74     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 6, 1 ); 73     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 46 ], 6, 1 );
75     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 74     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
76     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 75     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, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 76     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 78     const_str_digest_8350e2f18e8590ed1057414da0315e71 = UNSTREAM_STRING_ASCII( &constant_bin[ 67 ], 72, 0 ); n 77     const_str_digest_8350e2f18e8590ed1057414da0315e71 = UNSTREAM_STRING_ASCII( &constant_bin[ 52 ], 72, 0 );
79 78
80     constants_created = true; 79     constants_created = true;
81 } 80 }
82 81
83 #ifndef __NUITKA_NO_ASSERT__ 82 #ifndef __NUITKA_NO_ASSERT__
91 #endif 90 #endif
92 91
93 // The module code objects. 92 // The module code objects.
94 static PyCodeObject *codeobj_c94f71a6992d9edcdf031a678c750ac3; 93 static PyCodeObject *codeobj_c94f71a6992d9edcdf031a678c750ac3;
95 static PyCodeObject *codeobj_af2dd2c74e5581ab304eedf6d3251eef; 94 static PyCodeObject *codeobj_af2dd2c74e5581ab304eedf6d3251eef;
n 96 static PyCodeObject *codeobj_8099092e19b38d4526e886a82c27d6d5; 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_8350e2f18e8590ed1057414da0315e71; 100     module_filename_obj = const_str_digest_8350e2f18e8590ed1057414da0315e71;
103     codeobj_c94f71a6992d9edcdf031a678c750ac3 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 101     codeobj_c94f71a6992d9edcdf031a678c750ac3 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
104     codeobj_main = codeobj_c94f71a6992d9edcdf031a678c750ac3; 102     codeobj_main = codeobj_c94f71a6992d9edcdf031a678c750ac3;
105     codeobj_af2dd2c74e5581ab304eedf6d3251eef = 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_af2dd2c74e5581ab304eedf6d3251eef = 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_8099092e19b38d4526e886a82c27d6d5 = 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     CHECK_OBJECT( var_empty );
143     tmp_return_value = var_empty;
144     Py_INCREF( tmp_return_value ); 124     Py_INCREF( tmp_return_value );
n 145     goto try_return_handler_1; n
146     }
147     // tried codes exits in all cases
148     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
149     return NULL;
150     // Return handler code:
151     try_return_handler_1:;
152     {
153     CHECK_OBJECT( (PyObject *)var_empty );
154     Py_DECREF( var_empty );
155     var_empty = NULL;
156  
157     }
158     {
159     goto function_return_exit; 125     goto function_return_exit;
n 160     } n
161     // End of try:
162     } 126     }
163 127
164     // Return statement must have exited already. 128     // Return statement must have exited already.
165     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 129     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 166     return NULL; n
167  
168 function_return_exit:
169  
170 CHECK_OBJECT( tmp_return_value );
171 assert( had_error || !ERROR_OCCURRED() );
172 return tmp_return_value;
173  
174 }
175  
176  
177 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
178 {
179     // Preserve error status for checks
180 #ifndef __NUITKA_NO_ASSERT__
181     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
182 #endif
183  
184     // Local variable declarations.
185     PyObject *tmp_return_value = NULL;
186  
187     // Actual function code.
188     {
189     tmp_return_value = Py_None;
190     Py_INCREF( tmp_return_value );
191     goto function_return_exit;
192     }
193  
194     // Return statement must have exited already.
195     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
196     return NULL; 130     return NULL;
197 131
198 function_return_exit: 132 function_return_exit:
199 133
200 CHECK_OBJECT( tmp_return_value ); 134 CHECK_OBJECT( tmp_return_value );
212         const_str_plain_calledRepeatedly, 146         const_str_plain_calledRepeatedly,
213 #if PYTHON_VERSION >= 300 147 #if PYTHON_VERSION >= 300
214         NULL, 148         NULL,
215 #endif 149 #endif
216         codeobj_af2dd2c74e5581ab304eedf6d3251eef, 150         codeobj_af2dd2c74e5581ab304eedf6d3251eef,
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_8099092e19b38d4526e886a82c27d6d5,
241         NULL, 151         NULL,
242 #if PYTHON_VERSION >= 300 152 #if PYTHON_VERSION >= 300
243         NULL, 153         NULL,
244         NULL, 154         NULL,
245 #endif 155 #endif