Construct DictCreation

Performance Diagrams

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