Construct ListCreation

Performance Diagrams

Construct ListCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)5002668088.95192307692307257.0CPython 2.733852513242.31730769230768336.89507796716595Nuitka (master)33861435395.6826923076923336.8510062146223Nuitka (develop)33852597549.0480769230769336.8946630347277Nuitka (factory)Construct ListCreationTicks Construct ListCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5130172188.95192307692307257.0CPython 3.536755458242.31730769230768327.0679296112023Nuitka (master)36751636395.6826923076923327.0863398122948Nuitka (develop)36757458549.0480769230769327.0582958063397Nuitka (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 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 extern PyObject *const_str_plain_print; 39 extern PyObject *const_str_plain_print;
39 static PyObject *const_int_pos_50000; 40 static PyObject *const_int_pos_50000;
40 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 41 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
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_255ba8f0eb00bfa7e775a9daae961a0a; 123     struct Nuitka_FrameObject *frame_255ba8f0eb00bfa7e775a9daae961a0a;
124     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 124     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
125     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 125     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
126     PyObject *exception_type = NULL; 126     PyObject *exception_type = NULL;
127     PyObject *exception_value = NULL; 127     PyObject *exception_value = NULL;
128     PyTracebackObject *exception_tb = NULL; 128     PyTracebackObject *exception_tb = NULL;
129     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 129     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
130     static struct Nuitka_FrameObject *cache_frame_255ba8f0eb00bfa7e775a9daae961a0a = NULL; 130     static struct Nuitka_FrameObject *cache_frame_255ba8f0eb00bfa7e775a9daae961a0a = NULL;
n 131     PyObject *tmp_return_value = NULL; n
132     PyObject *exception_keeper_type_1; 131     PyObject *exception_keeper_type_1;
133     PyObject *exception_keeper_value_1; 132     PyObject *exception_keeper_value_1;
134     PyTracebackObject *exception_keeper_tb_1; 133     PyTracebackObject *exception_keeper_tb_1;
135     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 134     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n n 135     PyObject *tmp_return_value = NULL;
136 136
137     // Actual function code. 137     // Actual function code.
138     { 138     {
139     // Tried code: 139     // Tried code:
140     MAKE_OR_REUSE_FRAME( cache_frame_255ba8f0eb00bfa7e775a9daae961a0a, codeobj_255ba8f0eb00bfa7e775a9daae961a0a, module___main__, sizeof(void *) ); 140     MAKE_OR_REUSE_FRAME( cache_frame_255ba8f0eb00bfa7e775a9daae961a0a, codeobj_255ba8f0eb00bfa7e775a9daae961a0a, module___main__, sizeof(void *) );
164         exception_tb = NULL; 164         exception_tb = NULL;
165         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 165         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
166         CHAIN_EXCEPTION( exception_value ); 166         CHAIN_EXCEPTION( exception_value );
167 167
168         exception_lineno = 24; 168         exception_lineno = 24;
n 169         type_description_1 = "o"; n 169         type_description_1 = "N";
170         goto frame_exception_exit_1; 170         goto frame_exception_exit_1;
171     } 171     }
n 172   n
173     }
174     {
175     PyObject *tmp_assign_source_1;
176     PyObject *tmp_list_element_1;
177     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
178  
179     if (unlikely( tmp_list_element_1 == NULL ))
180     {
181         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
182     }
183  
184     if ( tmp_list_element_1 == NULL )
185     {
186  
187         exception_type = PyExc_NameError;
188         Py_INCREF( exception_type );
189         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
190         exception_tb = NULL;
191         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
192         CHAIN_EXCEPTION( exception_value );
193  
194         exception_lineno = 28;
195         type_description_1 = "o";
196         goto frame_exception_exit_1;
197     }
198  
199     tmp_assign_source_1 = PyList_New( 5 );
200     Py_INCREF( tmp_list_element_1 );
201     PyList_SET_ITEM( tmp_assign_source_1, 0, tmp_list_element_1 );
202     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
203  
204     if (unlikely( tmp_list_element_1 == NULL ))
205     {
206         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
207     }
208  
209     if ( tmp_list_element_1 == NULL )
210     {
211         Py_DECREF( tmp_assign_source_1 );
212         exception_type = PyExc_NameError;
213         Py_INCREF( exception_type );
214         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
215         exception_tb = NULL;
216         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
217         CHAIN_EXCEPTION( exception_value );
218  
219         exception_lineno = 29;
220         type_description_1 = "o";
221         goto frame_exception_exit_1;
222     }
223  
224     Py_INCREF( tmp_list_element_1 );
225     PyList_SET_ITEM( tmp_assign_source_1, 1, tmp_list_element_1 );
226     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
227  
228     if (unlikely( tmp_list_element_1 == NULL ))
229     {
230         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
231     }
232  
233     if ( tmp_list_element_1 == NULL )
234     {
235         Py_DECREF( tmp_assign_source_1 );
236         exception_type = PyExc_NameError;
237         Py_INCREF( exception_type );
238         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
239         exception_tb = NULL;
240         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
241         CHAIN_EXCEPTION( exception_value );
242  
243         exception_lineno = 30;
244         type_description_1 = "o";
245         goto frame_exception_exit_1;
246     }
247  
248     Py_INCREF( tmp_list_element_1 );
249     PyList_SET_ITEM( tmp_assign_source_1, 2, tmp_list_element_1 );
250     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
251  
252     if (unlikely( tmp_list_element_1 == NULL ))
253     {
254         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
255     }
256  
257     if ( tmp_list_element_1 == NULL )
258     {
259         Py_DECREF( tmp_assign_source_1 );
260         exception_type = PyExc_NameError;
261         Py_INCREF( exception_type );
262         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
263         exception_tb = NULL;
264         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
265         CHAIN_EXCEPTION( exception_value );
266  
267         exception_lineno = 31;
268         type_description_1 = "o";
269         goto frame_exception_exit_1;
270     }
271  
272     Py_INCREF( tmp_list_element_1 );
273     PyList_SET_ITEM( tmp_assign_source_1, 3, tmp_list_element_1 );
274     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
275  
276     if (unlikely( tmp_list_element_1 == NULL ))
277     {
278         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
279     }
280  
281     if ( tmp_list_element_1 == NULL )
282     {
283         Py_DECREF( tmp_assign_source_1 );
284         exception_type = PyExc_NameError;
285         Py_INCREF( exception_type );
286         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
287         exception_tb = NULL;
288         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
289         CHAIN_EXCEPTION( exception_value );
290  
291         exception_lineno = 32;
292         type_description_1 = "o";
293         goto frame_exception_exit_1;
294     }
295  
296     Py_INCREF( tmp_list_element_1 );
297     PyList_SET_ITEM( tmp_assign_source_1, 4, tmp_list_element_1 );
298     assert( var_l == NULL );
299     var_l = tmp_assign_source_1;
300 172
301     } 173     }
302 174
303 #if 0 175 #if 0
304     RESTORE_FRAME_EXCEPTION( frame_255ba8f0eb00bfa7e775a9daae961a0a ); 176     RESTORE_FRAME_EXCEPTION( frame_255ba8f0eb00bfa7e775a9daae961a0a );
326 198
327     // Attachs locals to frame if any. 199     // Attachs locals to frame if any.
328     Nuitka_Frame_AttachLocals( 200     Nuitka_Frame_AttachLocals(
329         (struct Nuitka_FrameObject *)frame_255ba8f0eb00bfa7e775a9daae961a0a, 201         (struct Nuitka_FrameObject *)frame_255ba8f0eb00bfa7e775a9daae961a0a,
330         type_description_1, 202         type_description_1,
n 331         var_l n 203         NULL
332     ); 204     );
333 205
334 206
335     // Release cached frame. 207     // Release cached frame.
336     if ( frame_255ba8f0eb00bfa7e775a9daae961a0a == cache_frame_255ba8f0eb00bfa7e775a9daae961a0a ) 208     if ( frame_255ba8f0eb00bfa7e775a9daae961a0a == cache_frame_255ba8f0eb00bfa7e775a9daae961a0a )
347     // Return the error. 219     // Return the error.
348     goto try_except_handler_1; 220     goto try_except_handler_1;
349 221
350     frame_no_exception_1:; 222     frame_no_exception_1:;
351 223
n 352     { n
353     tmp_return_value = var_l;
354  
355     CHECK_OBJECT( tmp_return_value );
356     Py_INCREF( tmp_return_value );
357     goto try_return_handler_1; 224     goto try_end_1;
358     }
359     // tried codes exits in all cases
360     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
361     return NULL;
362     // Return handler code:
363     try_return_handler_1:;
364     {
365     CHECK_OBJECT( (PyObject *)var_l );
366     Py_DECREF( var_l );
367     var_l = NULL;
368  
369     }
370     {
371     goto function_return_exit;
372     }
373     // Exception handler code: 225     // Exception handler code:
374     try_except_handler_1:; 226     try_except_handler_1:;
375     exception_keeper_type_1 = exception_type; 227     exception_keeper_type_1 = exception_type;
376     exception_keeper_value_1 = exception_value; 228     exception_keeper_value_1 = exception_value;
377     exception_keeper_tb_1 = exception_tb; 229     exception_keeper_tb_1 = exception_tb;
389     exception_lineno = exception_keeper_lineno_1; 241     exception_lineno = exception_keeper_lineno_1;
390 242
391     goto function_exception_exit; 243     goto function_exception_exit;
392     } 244     }
393     // End of try: 245     // End of try:
t t 246     try_end_1:;
247     }
248     {
249     tmp_return_value = const_int_pos_1;
250     Py_INCREF( tmp_return_value );
251     goto function_return_exit;
394     } 252     }
395 253
396     // Return statement must have exited already. 254     // Return statement must have exited already.
397     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 255     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
398     return NULL; 256     return NULL;