Construct DictCreation

Performance Diagrams

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