Construct ListCreation

Performance Diagrams

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