Construct ListCreation

Performance Diagrams

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