Construct DictCreation

Performance Diagrams

Construct DictCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000600000006000000070000000700000008000000080000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)8387729788.95192307692307257.0CPython 2.752501269242.31730769230768349.4385918983903Nuitka (master)52499942395.6826923076923349.44250144396597Nuitka (develop)52500626549.0480769230769349.4404862750332Nuitka (factory)Construct DictCreationTicks Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)10425103388.11538461538461257.0CPython 3.578446600240.03846153846155318.1665151133507Nuitka (master)78301413391.96153846153845318.5106646178084Nuitka (develop)78304761543.8846153846154318.5027285592017Nuitka (factory)Construct DictCreationTicks

Source Code with Construct

module_value1 = module_value2 = module_value3 = module_value4 = 1000
module_key1 = module_key2 = module_key3 = module_key4 = 1000

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

# construct_begin
    l = {
        module_key1 : module_value1,
        module_key2 : module_value2,
        module_key3 : module_value3,
        module_key4 : module_value4
    }
# construct_alternative



    return l

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

print("OK.")

Source Code without Construct

module_value1 = module_value2 = module_value3 = module_value4 = 1000
module_key1 = module_key2 = module_key3 = module_key4 = 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
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # Force frame and eliminate forward propagation (currently). 24     # Force frame and eliminate forward propagation (currently).
25     module_value1 25     module_value1
26 26
27 # construct_begin 27 # construct_begin
n 28     l = { n
29         module_key1 : module_value1,
30         module_key2 : module_value2,
31         module_key3 : module_value3,
32         module_key4 : module_value4
33     }
34 # construct_alternative
35 28
36 29
t t 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
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_plain_module_key4; 36 static PyObject *const_str_plain_module_key4;
37 static PyObject *const_str_plain_module_value4; 37 static PyObject *const_str_plain_module_value4;
38 static PyObject *const_str_plain_module_key3; 38 static PyObject *const_str_plain_module_key3;
n n 39 extern PyObject *const_int_pos_1;
39 extern PyObject *const_str_plain___file__; 40 extern PyObject *const_str_plain___file__;
40 extern PyObject *const_int_0; 41 extern PyObject *const_int_0;
41 static PyObject *const_str_plain_module_key2; 42 static PyObject *const_str_plain_module_key2;
42 extern PyObject *const_str_plain_print; 43 extern PyObject *const_str_plain_print;
43 static PyObject *const_int_pos_50000; 44 static PyObject *const_int_pos_50000;
134 #ifndef __NUITKA_NO_ASSERT__ 135 #ifndef __NUITKA_NO_ASSERT__
135     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 136     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
136 #endif 137 #endif
137 138
138     // Local variable declarations. 139     // Local variable declarations.
n 139     PyObject *var_l = NULL; n
140     struct Nuitka_FrameObject *frame_2cf5e0efa4ec010df378922ded7b275e; 140     struct Nuitka_FrameObject *frame_2cf5e0efa4ec010df378922ded7b275e;
141     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 141     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
142     PyObject *exception_type = NULL; 142     PyObject *exception_type = NULL;
143     PyObject *exception_value = NULL; 143     PyObject *exception_value = NULL;
144     PyTracebackObject *exception_tb = NULL; 144     PyTracebackObject *exception_tb = NULL;
145     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 145     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 146     int tmp_res; n
147     static struct Nuitka_FrameObject *cache_frame_2cf5e0efa4ec010df378922ded7b275e = NULL; 146     static struct Nuitka_FrameObject *cache_frame_2cf5e0efa4ec010df378922ded7b275e = NULL;
148     PyObject *tmp_return_value = NULL; 147     PyObject *tmp_return_value = NULL;
n 149     PyObject *exception_keeper_type_1; n
150     PyObject *exception_keeper_value_1;
151     PyTracebackObject *exception_keeper_tb_1;
152     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
153 148
154     // Actual function body. 149     // Actual function body.
n 155     // Tried code: n
156     MAKE_OR_REUSE_FRAME( cache_frame_2cf5e0efa4ec010df378922ded7b275e, codeobj_2cf5e0efa4ec010df378922ded7b275e, module___main__, sizeof(void *) ); 150     MAKE_OR_REUSE_FRAME( cache_frame_2cf5e0efa4ec010df378922ded7b275e, codeobj_2cf5e0efa4ec010df378922ded7b275e, module___main__, sizeof(void *) );
157     frame_2cf5e0efa4ec010df378922ded7b275e = cache_frame_2cf5e0efa4ec010df378922ded7b275e; 151     frame_2cf5e0efa4ec010df378922ded7b275e = cache_frame_2cf5e0efa4ec010df378922ded7b275e;
158 152
159     // Push the new frame as the currently active one. 153     // Push the new frame as the currently active one.
160     pushFrameStack( frame_2cf5e0efa4ec010df378922ded7b275e ); 154     pushFrameStack( frame_2cf5e0efa4ec010df378922ded7b275e );
181             exception_tb = NULL; 175             exception_tb = NULL;
182             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 176             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
183             CHAIN_EXCEPTION( exception_value ); 177             CHAIN_EXCEPTION( exception_value );
184 178
185             exception_lineno = 25; 179             exception_lineno = 25;
n 186             type_description_1 = "o"; n 180             type_description_1 = "N";
187             goto frame_exception_exit_1; 181             goto frame_exception_exit_1;
188         } 182         }
189 183
n 190     } n
191     {
192         PyObject *tmp_assign_source_1;
193         PyObject *tmp_dict_key_1;
194         PyObject *tmp_dict_value_1;
195         PyObject *tmp_mvar_value_2;
196         PyObject *tmp_mvar_value_3;
197         PyObject *tmp_dict_key_2;
198         PyObject *tmp_dict_value_2;
199         PyObject *tmp_mvar_value_4;
200         PyObject *tmp_mvar_value_5;
201         PyObject *tmp_dict_key_3;
202         PyObject *tmp_dict_value_3;
203         PyObject *tmp_mvar_value_6;
204         PyObject *tmp_mvar_value_7;
205         PyObject *tmp_dict_key_4;
206         PyObject *tmp_dict_value_4;
207         PyObject *tmp_mvar_value_8;
208         PyObject *tmp_mvar_value_9;
209         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key1 );
210  
211         if (unlikely( tmp_mvar_value_2 == NULL ))
212         {
213             tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key1 );
214         }
215  
216         if ( tmp_mvar_value_2 == NULL )
217         {
218  
219             exception_type = PyExc_NameError;
220             Py_INCREF( exception_type );
221             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key1" );
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_dict_key_1 = tmp_mvar_value_2;
232         tmp_mvar_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
233  
234         if (unlikely( tmp_mvar_value_3 == NULL ))
235         {
236             tmp_mvar_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
237         }
238  
239         if ( tmp_mvar_value_3 == NULL )
240         {
241  
242             exception_type = PyExc_NameError;
243             Py_INCREF( exception_type );
244             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
245             exception_tb = NULL;
246             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
247             CHAIN_EXCEPTION( exception_value );
248  
249             exception_lineno = 29;
250             type_description_1 = "o";
251             goto frame_exception_exit_1;
252         }
253  
254         tmp_dict_value_1 = tmp_mvar_value_3;
255         tmp_assign_source_1 = _PyDict_NewPresized( 4 );
256         tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_1, tmp_dict_value_1 );
257         if ( tmp_res != 0 )
258         {
259             assert( ERROR_OCCURRED() );
260  
261             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
262             Py_DECREF( tmp_assign_source_1 );
263  
264             exception_lineno = 28;
265             type_description_1 = "o";
266             goto frame_exception_exit_1;
267         }
268         tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key2 );
269  
270         if (unlikely( tmp_mvar_value_4 == NULL ))
271         {
272             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key2 );
273         }
274  
275         if ( tmp_mvar_value_4 == NULL )
276         {
277             Py_DECREF( tmp_assign_source_1 );
278             exception_type = PyExc_NameError;
279             Py_INCREF( exception_type );
280             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key2" );
281             exception_tb = NULL;
282             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
283             CHAIN_EXCEPTION( exception_value );
284  
285             exception_lineno = 30;
286             type_description_1 = "o";
287             goto frame_exception_exit_1;
288         }
289  
290         tmp_dict_key_2 = tmp_mvar_value_4;
291         tmp_mvar_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 );
292  
293         if (unlikely( tmp_mvar_value_5 == NULL ))
294         {
295             tmp_mvar_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
296         }
297  
298         if ( tmp_mvar_value_5 == NULL )
299         {
300             Py_DECREF( tmp_assign_source_1 );
301             exception_type = PyExc_NameError;
302             Py_INCREF( exception_type );
303             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
304             exception_tb = NULL;
305             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
306             CHAIN_EXCEPTION( exception_value );
307  
308             exception_lineno = 30;
309             type_description_1 = "o";
310             goto frame_exception_exit_1;
311         }
312  
313         tmp_dict_value_2 = tmp_mvar_value_5;
314         tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_2, tmp_dict_value_2 );
315         if ( tmp_res != 0 )
316         {
317             assert( ERROR_OCCURRED() );
318  
319             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
320             Py_DECREF( tmp_assign_source_1 );
321  
322             exception_lineno = 28;
323             type_description_1 = "o";
324             goto frame_exception_exit_1;
325         }
326         tmp_mvar_value_6 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key3 );
327  
328         if (unlikely( tmp_mvar_value_6 == NULL ))
329         {
330             tmp_mvar_value_6 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key3 );
331         }
332  
333         if ( tmp_mvar_value_6 == NULL )
334         {
335             Py_DECREF( tmp_assign_source_1 );
336             exception_type = PyExc_NameError;
337             Py_INCREF( exception_type );
338             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key3" );
339             exception_tb = NULL;
340             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
341             CHAIN_EXCEPTION( exception_value );
342  
343             exception_lineno = 31;
344             type_description_1 = "o";
345             goto frame_exception_exit_1;
346         }
347  
348         tmp_dict_key_3 = tmp_mvar_value_6;
349         tmp_mvar_value_7 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
350  
351         if (unlikely( tmp_mvar_value_7 == NULL ))
352         {
353             tmp_mvar_value_7 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );
354         }
355  
356         if ( tmp_mvar_value_7 == NULL )
357         {
358             Py_DECREF( tmp_assign_source_1 );
359             exception_type = PyExc_NameError;
360             Py_INCREF( exception_type );
361             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value3" );
362             exception_tb = NULL;
363             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
364             CHAIN_EXCEPTION( exception_value );
365  
366             exception_lineno = 31;
367             type_description_1 = "o";
368             goto frame_exception_exit_1;
369         }
370  
371         tmp_dict_value_3 = tmp_mvar_value_7;
372         tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_3, tmp_dict_value_3 );
373         if ( tmp_res != 0 )
374         {
375             assert( ERROR_OCCURRED() );
376  
377             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
378             Py_DECREF( tmp_assign_source_1 );
379  
380             exception_lineno = 28;
381             type_description_1 = "o";
382             goto frame_exception_exit_1;
383         }
384         tmp_mvar_value_8 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key4 );
385  
386         if (unlikely( tmp_mvar_value_8 == NULL ))
387         {
388             tmp_mvar_value_8 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key4 );
389         }
390  
391         if ( tmp_mvar_value_8 == NULL )
392         {
393             Py_DECREF( tmp_assign_source_1 );
394             exception_type = PyExc_NameError;
395             Py_INCREF( exception_type );
396             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key4" );
397             exception_tb = NULL;
398             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
399             CHAIN_EXCEPTION( exception_value );
400  
401             exception_lineno = 32;
402             type_description_1 = "o";
403             goto frame_exception_exit_1;
404         }
405  
406         tmp_dict_key_4 = tmp_mvar_value_8;
407         tmp_mvar_value_9 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value4 );
408  
409         if (unlikely( tmp_mvar_value_9 == NULL ))
410         {
411             tmp_mvar_value_9 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value4 );
412         }
413  
414         if ( tmp_mvar_value_9 == NULL )
415         {
416             Py_DECREF( tmp_assign_source_1 );
417             exception_type = PyExc_NameError;
418             Py_INCREF( exception_type );
419             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value4" );
420             exception_tb = NULL;
421             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
422             CHAIN_EXCEPTION( exception_value );
423  
424             exception_lineno = 32;
425             type_description_1 = "o";
426             goto frame_exception_exit_1;
427         }
428  
429         tmp_dict_value_4 = tmp_mvar_value_9;
430         tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_4, tmp_dict_value_4 );
431         if ( tmp_res != 0 )
432         {
433             assert( ERROR_OCCURRED() );
434  
435             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
436             Py_DECREF( tmp_assign_source_1 );
437  
438             exception_lineno = 28;
439             type_description_1 = "o";
440             goto frame_exception_exit_1;
441         }
442         assert( var_l == NULL );
443         var_l = tmp_assign_source_1;
444     } 184     }
445 185
446 #if 0 186 #if 0
447     RESTORE_FRAME_EXCEPTION( frame_2cf5e0efa4ec010df378922ded7b275e ); 187     RESTORE_FRAME_EXCEPTION( frame_2cf5e0efa4ec010df378922ded7b275e );
448 #endif 188 #endif
469 209
470     // Attachs locals to frame if any. 210     // Attachs locals to frame if any.
471     Nuitka_Frame_AttachLocals( 211     Nuitka_Frame_AttachLocals(
472         (struct Nuitka_FrameObject *)frame_2cf5e0efa4ec010df378922ded7b275e, 212         (struct Nuitka_FrameObject *)frame_2cf5e0efa4ec010df378922ded7b275e,
473         type_description_1, 213         type_description_1,
n 474         var_l n 214         NULL
475     ); 215     );
476 216
477 217
478     // Release cached frame. 218     // Release cached frame.
479     if ( frame_2cf5e0efa4ec010df378922ded7b275e == cache_frame_2cf5e0efa4ec010df378922ded7b275e ) 219     if ( frame_2cf5e0efa4ec010df378922ded7b275e == cache_frame_2cf5e0efa4ec010df378922ded7b275e )
486 226
487     // Put the previous frame back on top. 227     // Put the previous frame back on top.
488     popFrameStack(); 228     popFrameStack();
489 229
490     // Return the error. 230     // Return the error.
n 491     goto try_except_handler_1; n 231     goto function_exception_exit;
492 232
493     frame_no_exception_1:; 233     frame_no_exception_1:;
n 494     CHECK_OBJECT( var_l ); n 234     tmp_return_value = const_int_pos_1;
495     tmp_return_value = var_l;
496     Py_INCREF( tmp_return_value ); 235     Py_INCREF( tmp_return_value );
n 497     goto try_return_handler_1; n
498     // tried codes exits in all cases
499     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
500     return NULL;
501     // Return handler code:
502     try_return_handler_1:;
503     CHECK_OBJECT( (PyObject *)var_l );
504     Py_DECREF( var_l );
505     var_l = NULL;
506  
507     goto function_return_exit; 236     goto function_return_exit;
t 508     // Exception handler code: t
509     try_except_handler_1:;
510     exception_keeper_type_1 = exception_type;
511     exception_keeper_value_1 = exception_value;
512     exception_keeper_tb_1 = exception_tb;
513     exception_keeper_lineno_1 = exception_lineno;
514     exception_type = NULL;
515     exception_value = NULL;
516     exception_tb = NULL;
517     exception_lineno = 0;
518  
519     // Re-raise.
520     exception_type = exception_keeper_type_1;
521     exception_value = exception_keeper_value_1;
522     exception_tb = exception_keeper_tb_1;
523     exception_lineno = exception_keeper_lineno_1;
524  
525     goto function_exception_exit;
526     // End of try:
527 237
528     // Return statement must have exited already. 238     // Return statement must have exited already.
529     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 239     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
530     return NULL; 240     return NULL;
531 241