Construct DictCreation

Performance Diagrams

Construct DictCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000600000006000000070000000700000008000000080000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)8491826688.95192307692307257.0CPython 2.752499952242.31730769230768351.33852703365733Nuitka (master)52500025395.6826923076923351.3383146008802Nuitka (develop)52500127549.0480769230769351.3380177769998Nuitka (factory)Construct DictCreationTicks Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)10310104688.11538461538461257.0CPython 3.575900588240.03846153846155322.1947957965879Nuitka (master)75894076391.96153846153845322.21040393488573Nuitka (develop)75900792543.8846153846154322.1943068438526Nuitka (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_4fac55996a93f64313eb93acaa9f4811; 37 static PyObject *const_str_digest_4fac55996a93f64313eb93acaa9f4811;
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;
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_a97935b7d86f0b56241e6fb7cfc9b571; 137     struct Nuitka_FrameObject *frame_a97935b7d86f0b56241e6fb7cfc9b571;
138     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 138     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
139     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 139     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
140     PyObject *exception_type = NULL; 140     PyObject *exception_type = NULL;
141     PyObject *exception_value = NULL; 141     PyObject *exception_value = NULL;
142     PyTracebackObject *exception_tb = NULL; 142     PyTracebackObject *exception_tb = NULL;
143     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 143     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 144     int tmp_res; n
145     static struct Nuitka_FrameObject *cache_frame_a97935b7d86f0b56241e6fb7cfc9b571 = NULL; 144     static struct Nuitka_FrameObject *cache_frame_a97935b7d86f0b56241e6fb7cfc9b571 = NULL;
n 146     PyObject *tmp_return_value = NULL; n
147     PyObject *exception_keeper_type_1; 145     PyObject *exception_keeper_type_1;
148     PyObject *exception_keeper_value_1; 146     PyObject *exception_keeper_value_1;
149     PyTracebackObject *exception_keeper_tb_1; 147     PyTracebackObject *exception_keeper_tb_1;
150     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 148     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n n 149     PyObject *tmp_return_value = NULL;
151 150
152     // Actual function code. 151     // Actual function code.
153     { 152     {
154     // Tried code: 153     // Tried code:
155     MAKE_OR_REUSE_FRAME( cache_frame_a97935b7d86f0b56241e6fb7cfc9b571, codeobj_a97935b7d86f0b56241e6fb7cfc9b571, module___main__, sizeof(void *) ); 154     MAKE_OR_REUSE_FRAME( cache_frame_a97935b7d86f0b56241e6fb7cfc9b571, codeobj_a97935b7d86f0b56241e6fb7cfc9b571, module___main__, sizeof(void *) );
179         exception_tb = NULL; 178         exception_tb = NULL;
180         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 179         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
181         CHAIN_EXCEPTION( exception_value ); 180         CHAIN_EXCEPTION( exception_value );
182 181
183         exception_lineno = 25; 182         exception_lineno = 25;
n 184         type_description_1 = "o"; n 183         type_description_1 = "N";
185         goto frame_exception_exit_1; 184         goto frame_exception_exit_1;
186     } 185     }
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_dict_key_2;
194     PyObject *tmp_dict_value_2;
195     PyObject *tmp_dict_key_3;
196     PyObject *tmp_dict_value_3;
197     PyObject *tmp_dict_key_4;
198     PyObject *tmp_dict_value_4;
199     tmp_dict_key_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key1 );
200  
201     if (unlikely( tmp_dict_key_1 == NULL ))
202     {
203         tmp_dict_key_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key1 );
204     }
205  
206     if ( tmp_dict_key_1 == NULL )
207     {
208  
209         exception_type = PyExc_NameError;
210         Py_INCREF( exception_type );
211         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key1" );
212         exception_tb = NULL;
213         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
214         CHAIN_EXCEPTION( exception_value );
215  
216         exception_lineno = 29;
217         type_description_1 = "o";
218         goto frame_exception_exit_1;
219     }
220  
221     tmp_dict_value_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
222  
223     if (unlikely( tmp_dict_value_1 == NULL ))
224     {
225         tmp_dict_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
226     }
227  
228     if ( tmp_dict_value_1 == NULL )
229     {
230  
231         exception_type = PyExc_NameError;
232         Py_INCREF( exception_type );
233         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
234         exception_tb = NULL;
235         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
236         CHAIN_EXCEPTION( exception_value );
237  
238         exception_lineno = 29;
239         type_description_1 = "o";
240         goto frame_exception_exit_1;
241     }
242  
243     tmp_assign_source_1 = _PyDict_NewPresized( 4 );
244     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_1, tmp_dict_value_1 );
245     if ( tmp_res != 0 )
246     {
247         assert( ERROR_OCCURRED() );
248  
249         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
250         Py_DECREF( tmp_assign_source_1 );
251  
252         exception_lineno = 28;
253         type_description_1 = "o";
254         goto frame_exception_exit_1;
255     }
256     tmp_dict_key_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key2 );
257  
258     if (unlikely( tmp_dict_key_2 == NULL ))
259     {
260         tmp_dict_key_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key2 );
261     }
262  
263     if ( tmp_dict_key_2 == NULL )
264     {
265         Py_DECREF( tmp_assign_source_1 );
266         exception_type = PyExc_NameError;
267         Py_INCREF( exception_type );
268         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key2" );
269         exception_tb = NULL;
270         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
271         CHAIN_EXCEPTION( exception_value );
272  
273         exception_lineno = 30;
274         type_description_1 = "o";
275         goto frame_exception_exit_1;
276     }
277  
278     tmp_dict_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 );
279  
280     if (unlikely( tmp_dict_value_2 == NULL ))
281     {
282         tmp_dict_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
283     }
284  
285     if ( tmp_dict_value_2 == NULL )
286     {
287         Py_DECREF( tmp_assign_source_1 );
288         exception_type = PyExc_NameError;
289         Py_INCREF( exception_type );
290         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
291         exception_tb = NULL;
292         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
293         CHAIN_EXCEPTION( exception_value );
294  
295         exception_lineno = 30;
296         type_description_1 = "o";
297         goto frame_exception_exit_1;
298     }
299  
300     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_2, tmp_dict_value_2 );
301     if ( tmp_res != 0 )
302     {
303         assert( ERROR_OCCURRED() );
304  
305         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
306         Py_DECREF( tmp_assign_source_1 );
307  
308         exception_lineno = 28;
309         type_description_1 = "o";
310         goto frame_exception_exit_1;
311     }
312     tmp_dict_key_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key3 );
313  
314     if (unlikely( tmp_dict_key_3 == NULL ))
315     {
316         tmp_dict_key_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key3 );
317     }
318  
319     if ( tmp_dict_key_3 == NULL )
320     {
321         Py_DECREF( tmp_assign_source_1 );
322         exception_type = PyExc_NameError;
323         Py_INCREF( exception_type );
324         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key3" );
325         exception_tb = NULL;
326         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
327         CHAIN_EXCEPTION( exception_value );
328  
329         exception_lineno = 31;
330         type_description_1 = "o";
331         goto frame_exception_exit_1;
332     }
333  
334     tmp_dict_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
335  
336     if (unlikely( tmp_dict_value_3 == NULL ))
337     {
338         tmp_dict_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );
339     }
340  
341     if ( tmp_dict_value_3 == NULL )
342     {
343         Py_DECREF( tmp_assign_source_1 );
344         exception_type = PyExc_NameError;
345         Py_INCREF( exception_type );
346         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value3" );
347         exception_tb = NULL;
348         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
349         CHAIN_EXCEPTION( exception_value );
350  
351         exception_lineno = 31;
352         type_description_1 = "o";
353         goto frame_exception_exit_1;
354     }
355  
356     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_3, tmp_dict_value_3 );
357     if ( tmp_res != 0 )
358     {
359         assert( ERROR_OCCURRED() );
360  
361         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
362         Py_DECREF( tmp_assign_source_1 );
363  
364         exception_lineno = 28;
365         type_description_1 = "o";
366         goto frame_exception_exit_1;
367     }
368     tmp_dict_key_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key4 );
369  
370     if (unlikely( tmp_dict_key_4 == NULL ))
371     {
372         tmp_dict_key_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key4 );
373     }
374  
375     if ( tmp_dict_key_4 == NULL )
376     {
377         Py_DECREF( tmp_assign_source_1 );
378         exception_type = PyExc_NameError;
379         Py_INCREF( exception_type );
380         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key4" );
381         exception_tb = NULL;
382         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
383         CHAIN_EXCEPTION( exception_value );
384  
385         exception_lineno = 32;
386         type_description_1 = "o";
387         goto frame_exception_exit_1;
388     }
389  
390     tmp_dict_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value4 );
391  
392     if (unlikely( tmp_dict_value_4 == NULL ))
393     {
394         tmp_dict_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value4 );
395     }
396  
397     if ( tmp_dict_value_4 == NULL )
398     {
399         Py_DECREF( tmp_assign_source_1 );
400         exception_type = PyExc_NameError;
401         Py_INCREF( exception_type );
402         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value4" );
403         exception_tb = NULL;
404         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
405         CHAIN_EXCEPTION( exception_value );
406  
407         exception_lineno = 32;
408         type_description_1 = "o";
409         goto frame_exception_exit_1;
410     }
411  
412     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_4, tmp_dict_value_4 );
413     if ( tmp_res != 0 )
414     {
415         assert( ERROR_OCCURRED() );
416  
417         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
418         Py_DECREF( tmp_assign_source_1 );
419  
420         exception_lineno = 28;
421         type_description_1 = "o";
422         goto frame_exception_exit_1;
423     }
424     assert( var_l == NULL );
425     var_l = tmp_assign_source_1;
426 186
427     } 187     }
428 188
429 #if 0 189 #if 0
430     RESTORE_FRAME_EXCEPTION( frame_a97935b7d86f0b56241e6fb7cfc9b571 ); 190     RESTORE_FRAME_EXCEPTION( frame_a97935b7d86f0b56241e6fb7cfc9b571 );
452 212
453     // Attachs locals to frame if any. 213     // Attachs locals to frame if any.
454     Nuitka_Frame_AttachLocals( 214     Nuitka_Frame_AttachLocals(
455         (struct Nuitka_FrameObject *)frame_a97935b7d86f0b56241e6fb7cfc9b571, 215         (struct Nuitka_FrameObject *)frame_a97935b7d86f0b56241e6fb7cfc9b571,
456         type_description_1, 216         type_description_1,
n 457         var_l n 217         NULL
458     ); 218     );
459 219
460 220
461     // Release cached frame. 221     // Release cached frame.
462     if ( frame_a97935b7d86f0b56241e6fb7cfc9b571 == cache_frame_a97935b7d86f0b56241e6fb7cfc9b571 ) 222     if ( frame_a97935b7d86f0b56241e6fb7cfc9b571 == cache_frame_a97935b7d86f0b56241e6fb7cfc9b571 )
473     // Return the error. 233     // Return the error.
474     goto try_except_handler_1; 234     goto try_except_handler_1;
475 235
476     frame_no_exception_1:; 236     frame_no_exception_1:;
477 237
n 478     { n
479     tmp_return_value = var_l;
480  
481     CHECK_OBJECT( tmp_return_value );
482     Py_INCREF( tmp_return_value );
483     goto try_return_handler_1; 238     goto try_end_1;
484     }
485     // tried codes exits in all cases
486     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
487     return NULL;
488     // Return handler code:
489     try_return_handler_1:;
490     {
491     CHECK_OBJECT( (PyObject *)var_l );
492     Py_DECREF( var_l );
493     var_l = NULL;
494  
495     }
496     {
497     goto function_return_exit;
498     }
499     // Exception handler code: 239     // Exception handler code:
500     try_except_handler_1:; 240     try_except_handler_1:;
501     exception_keeper_type_1 = exception_type; 241     exception_keeper_type_1 = exception_type;
502     exception_keeper_value_1 = exception_value; 242     exception_keeper_value_1 = exception_value;
503     exception_keeper_tb_1 = exception_tb; 243     exception_keeper_tb_1 = exception_tb;
515     exception_lineno = exception_keeper_lineno_1; 255     exception_lineno = exception_keeper_lineno_1;
516 256
517     goto function_exception_exit; 257     goto function_exception_exit;
518     } 258     }
519     // End of try: 259     // End of try:
t t 260     try_end_1:;
261     }
262     {
263     tmp_return_value = const_int_pos_1;
264     Py_INCREF( tmp_return_value );
265     goto function_return_exit;
520     } 266     }
521 267
522     // Return statement must have exited already. 268     // Return statement must have exited already.
523     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 269     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
524     return NULL; 270     return NULL;