Construct ListCreation

Performance Diagrams

Construct ListCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4938058788.95192307692307257.0CPython 2.733851900242.31730769230768334.7102439178563Nuitka (master)33852481395.6826923076923334.70733641822574Nuitka (develop)33852355549.0480769230769334.70796696031425Nuitka (factory)Construct ListCreationTicks Construct ListCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5215259288.95192307692307257.0CPython 3.536766262242.31730769230768329.9052710509428Nuitka (master)36752591395.6826923076923329.9700485489256Nuitka (develop)36755685549.0480769230769329.95538820376Nuitka (factory)Construct ListCreationTicks

Source Code with Construct

module_value1 = 1000

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

# construct_begin
    l = [
        module_value1,
        module_value1,
        module_value1,
        module_value1,
        module_value1
    ]
# construct_alternative



    return l

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

# construct_begin







# construct_alternative
    l = 1
# construct_end

    return l

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
22 def calledRepeatedly(): 22 def calledRepeatedly():
23     # Force frame and eliminate forward propagation (currently). 23     # Force frame and eliminate forward propagation (currently).
24     module_value1 24     module_value1
25 25
26 # construct_begin 26 # construct_begin
n 27     l = [ n
28         module_value1,
29         module_value1,
30         module_value1,
31         module_value1,
32         module_value1
33     ]
34 # construct_alternative
35 27
36 28
t t 29  
30  
31  
32  
33  
34 # construct_alternative
35     l = 1
36 # construct_end
37 37
38     return l 38     return l
39 39
40 import itertools 40 import itertools
41 for x in itertools.repeat(None, 50000): 41 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
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_l_tuple; 35 static PyObject *const_tuple_str_plain_l_tuple;
36 static PyObject *const_str_digest_5821c35a5b07cd05437e82491b423748; 36 static PyObject *const_str_digest_5821c35a5b07cd05437e82491b423748;
n n 37 extern PyObject *const_int_pos_1;
37 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
38 extern PyObject *const_int_0; 39 extern PyObject *const_int_0;
39 extern PyObject *const_str_plain_print; 40 extern PyObject *const_str_plain_print;
40 static PyObject *const_int_pos_50000; 41 static PyObject *const_int_pos_50000;
41 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
120 #ifndef __NUITKA_NO_ASSERT__ 121 #ifndef __NUITKA_NO_ASSERT__
121     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 122     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
122 #endif 123 #endif
123 124
124     // Local variable declarations. 125     // Local variable declarations.
n 125     PyObject *var_l = NULL; n
126     struct Nuitka_FrameObject *frame_7fc752ed3d4e2b70e14bd0b3a11a4e63; 126     struct Nuitka_FrameObject *frame_7fc752ed3d4e2b70e14bd0b3a11a4e63;
127     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 127     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
128     PyObject *exception_type = NULL; 128     PyObject *exception_type = NULL;
129     PyObject *exception_value = NULL; 129     PyObject *exception_value = NULL;
130     PyTracebackObject *exception_tb = NULL; 130     PyTracebackObject *exception_tb = NULL;
131     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 131     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
132     static struct Nuitka_FrameObject *cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 = NULL; 132     static struct Nuitka_FrameObject *cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 = NULL;
133     PyObject *tmp_return_value = NULL; 133     PyObject *tmp_return_value = NULL;
n 134     PyObject *exception_keeper_type_1; n
135     PyObject *exception_keeper_value_1;
136     PyTracebackObject *exception_keeper_tb_1;
137     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
138 134
139     // Actual function body. 135     // Actual function body.
n 140     // Tried code: n
141     MAKE_OR_REUSE_FRAME( cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63, codeobj_7fc752ed3d4e2b70e14bd0b3a11a4e63, module___main__, sizeof(void *) ); 136     MAKE_OR_REUSE_FRAME( cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63, codeobj_7fc752ed3d4e2b70e14bd0b3a11a4e63, module___main__, sizeof(void *) );
142     frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 = cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63; 137     frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 = cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63;
143 138
144     // Push the new frame as the currently active one. 139     // Push the new frame as the currently active one.
145     pushFrameStack( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 ); 140     pushFrameStack( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 );
166             exception_tb = NULL; 161             exception_tb = NULL;
167             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 162             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
168             CHAIN_EXCEPTION( exception_value ); 163             CHAIN_EXCEPTION( exception_value );
169 164
170             exception_lineno = 24; 165             exception_lineno = 24;
n 171             type_description_1 = "o"; n 166             type_description_1 = "N";
172             goto frame_exception_exit_1; 167             goto frame_exception_exit_1;
173         } 168         }
174 169
n 175     } n
176     {
177         PyObject *tmp_assign_source_1;
178         PyObject *tmp_list_element_1;
179         PyObject *tmp_mvar_value_2;
180         PyObject *tmp_mvar_value_3;
181         PyObject *tmp_mvar_value_4;
182         PyObject *tmp_mvar_value_5;
183         PyObject *tmp_mvar_value_6;
184         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
185  
186         if (unlikely( tmp_mvar_value_2 == NULL ))
187         {
188             tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
189         }
190  
191         if ( tmp_mvar_value_2 == NULL )
192         {
193  
194             exception_type = PyExc_NameError;
195             Py_INCREF( exception_type );
196             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
197             exception_tb = NULL;
198             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
199             CHAIN_EXCEPTION( exception_value );
200  
201             exception_lineno = 28;
202             type_description_1 = "o";
203             goto frame_exception_exit_1;
204         }
205  
206         tmp_list_element_1 = tmp_mvar_value_2;
207         tmp_assign_source_1 = PyList_New( 5 );
208         Py_INCREF( tmp_list_element_1 );
209         PyList_SET_ITEM( tmp_assign_source_1, 0, tmp_list_element_1 );
210         tmp_mvar_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
211  
212         if (unlikely( tmp_mvar_value_3 == NULL ))
213         {
214             tmp_mvar_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
215         }
216  
217         if ( tmp_mvar_value_3 == NULL )
218         {
219             Py_DECREF( tmp_assign_source_1 );
220             exception_type = PyExc_NameError;
221             Py_INCREF( exception_type );
222             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
223             exception_tb = NULL;
224             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
225             CHAIN_EXCEPTION( exception_value );
226  
227             exception_lineno = 29;
228             type_description_1 = "o";
229             goto frame_exception_exit_1;
230         }
231  
232         tmp_list_element_1 = tmp_mvar_value_3;
233         Py_INCREF( tmp_list_element_1 );
234         PyList_SET_ITEM( tmp_assign_source_1, 1, tmp_list_element_1 );
235         tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
236  
237         if (unlikely( tmp_mvar_value_4 == NULL ))
238         {
239             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
240         }
241  
242         if ( tmp_mvar_value_4 == NULL )
243         {
244             Py_DECREF( tmp_assign_source_1 );
245             exception_type = PyExc_NameError;
246             Py_INCREF( exception_type );
247             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
248             exception_tb = NULL;
249             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
250             CHAIN_EXCEPTION( exception_value );
251  
252             exception_lineno = 30;
253             type_description_1 = "o";
254             goto frame_exception_exit_1;
255         }
256  
257         tmp_list_element_1 = tmp_mvar_value_4;
258         Py_INCREF( tmp_list_element_1 );
259         PyList_SET_ITEM( tmp_assign_source_1, 2, tmp_list_element_1 );
260         tmp_mvar_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
261  
262         if (unlikely( tmp_mvar_value_5 == NULL ))
263         {
264             tmp_mvar_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
265         }
266  
267         if ( tmp_mvar_value_5 == NULL )
268         {
269             Py_DECREF( tmp_assign_source_1 );
270             exception_type = PyExc_NameError;
271             Py_INCREF( exception_type );
272             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
273             exception_tb = NULL;
274             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
275             CHAIN_EXCEPTION( exception_value );
276  
277             exception_lineno = 31;
278             type_description_1 = "o";
279             goto frame_exception_exit_1;
280         }
281  
282         tmp_list_element_1 = tmp_mvar_value_5;
283         Py_INCREF( tmp_list_element_1 );
284         PyList_SET_ITEM( tmp_assign_source_1, 3, tmp_list_element_1 );
285         tmp_mvar_value_6 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
286  
287         if (unlikely( tmp_mvar_value_6 == NULL ))
288         {
289             tmp_mvar_value_6 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
290         }
291  
292         if ( tmp_mvar_value_6 == NULL )
293         {
294             Py_DECREF( tmp_assign_source_1 );
295             exception_type = PyExc_NameError;
296             Py_INCREF( exception_type );
297             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
298             exception_tb = NULL;
299             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
300             CHAIN_EXCEPTION( exception_value );
301  
302             exception_lineno = 32;
303             type_description_1 = "o";
304             goto frame_exception_exit_1;
305         }
306  
307         tmp_list_element_1 = tmp_mvar_value_6;
308         Py_INCREF( tmp_list_element_1 );
309         PyList_SET_ITEM( tmp_assign_source_1, 4, tmp_list_element_1 );
310         assert( var_l == NULL );
311         var_l = tmp_assign_source_1;
312     } 170     }
313 171
314 #if 0 172 #if 0
315     RESTORE_FRAME_EXCEPTION( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 ); 173     RESTORE_FRAME_EXCEPTION( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 );
316 #endif 174 #endif
337 195
338     // Attachs locals to frame if any. 196     // Attachs locals to frame if any.
339     Nuitka_Frame_AttachLocals( 197     Nuitka_Frame_AttachLocals(
340         (struct Nuitka_FrameObject *)frame_7fc752ed3d4e2b70e14bd0b3a11a4e63, 198         (struct Nuitka_FrameObject *)frame_7fc752ed3d4e2b70e14bd0b3a11a4e63,
341         type_description_1, 199         type_description_1,
n 342         var_l n 200         NULL
343     ); 201     );
344 202
345 203
346     // Release cached frame. 204     // Release cached frame.
347     if ( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 == cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 ) 205     if ( frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 == cache_frame_7fc752ed3d4e2b70e14bd0b3a11a4e63 )
354 212
355     // Put the previous frame back on top. 213     // Put the previous frame back on top.
356     popFrameStack(); 214     popFrameStack();
357 215
358     // Return the error. 216     // Return the error.
n 359     goto try_except_handler_1; n 217     goto function_exception_exit;
360 218
361     frame_no_exception_1:; 219     frame_no_exception_1:;
n 362     CHECK_OBJECT( var_l ); n 220     tmp_return_value = const_int_pos_1;
363     tmp_return_value = var_l;
364     Py_INCREF( tmp_return_value ); 221     Py_INCREF( tmp_return_value );
n 365     goto try_return_handler_1; n
366     // tried codes exits in all cases
367     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
368     return NULL;
369     // Return handler code:
370     try_return_handler_1:;
371     CHECK_OBJECT( (PyObject *)var_l );
372     Py_DECREF( var_l );
373     var_l = NULL;
374  
375     goto function_return_exit; 222     goto function_return_exit;
t 376     // Exception handler code: t
377     try_except_handler_1:;
378     exception_keeper_type_1 = exception_type;
379     exception_keeper_value_1 = exception_value;
380     exception_keeper_tb_1 = exception_tb;
381     exception_keeper_lineno_1 = exception_lineno;
382     exception_type = NULL;
383     exception_value = NULL;
384     exception_tb = NULL;
385     exception_lineno = 0;
386  
387     // Re-raise.
388     exception_type = exception_keeper_type_1;
389     exception_value = exception_keeper_value_1;
390     exception_tb = exception_keeper_tb_1;
391     exception_lineno = exception_keeper_lineno_1;
392  
393     goto function_exception_exit;
394     // End of try:
395 223
396     // Return statement must have exited already. 224     // Return statement must have exited already.
397     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 225     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
398     return NULL; 226     return NULL;
399 227