Construct DictCreation

Performance Diagrams

Construct DictCreation 001000000010000000200000002000000030000000300000004000000040000000500000005000000060000000600000007000000070000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)7663980888.95192307692307257.0CPython 2.750100434242.31730769230768342.57286069220766Nuitka (master)50099726395.6826923076923342.57514354881795Nuitka (develop)50101424549.0480769230769342.5696685622016Nuitka (factory)Construct DictCreationTicks Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)10571257688.11538461538461257.0CPython 3.574301587240.03846153846155330.4268231992059Nuitka (master)74294315391.96153846153845330.4438223410764Nuitka (develop)74295555543.8846153846154330.44092369752315Nuitka (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
36 static PyObject *const_str_plain___package__; 36 static PyObject *const_str_plain___package__;
37 static PyObject *const_str_plain___spec__; 37 static PyObject *const_str_plain___spec__;
38 static PyObject *const_str_plain_module_key4; 38 static PyObject *const_str_plain_module_key4;
39 static PyObject *const_str_plain_module_value4; 39 static PyObject *const_str_plain_module_value4;
40 static PyObject *const_str_plain_module_key3; 40 static PyObject *const_str_plain_module_key3;
n n 41 extern PyObject *const_int_pos_1;
41 extern PyObject *const_dict_empty; 42 extern PyObject *const_dict_empty;
42 extern PyObject *const_str_plain___file__; 43 extern PyObject *const_str_plain___file__;
43 extern PyObject *const_int_0; 44 extern PyObject *const_int_0;
44 static PyObject *const_str_plain_module_key2; 45 static PyObject *const_str_plain_module_key2;
45 extern PyObject *const_str_plain_print; 46 extern PyObject *const_str_plain_print;
135 #ifndef __NUITKA_NO_ASSERT__ 136 #ifndef __NUITKA_NO_ASSERT__
136     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 137     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
137 #endif 138 #endif
138 139
139     // Local variable declarations. 140     // Local variable declarations.
n 140     PyObject *var_l = NULL; n
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;
145     PyObject *exception_keeper_type_1; 145     PyObject *exception_keeper_type_1;
146     PyObject *exception_keeper_value_1; 146     PyObject *exception_keeper_value_1;
147     PyTracebackObject *exception_keeper_tb_1; 147     PyTracebackObject *exception_keeper_tb_1;
148     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 148     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 149     PyObject *tmp_assign_source_1; n
150     PyObject *tmp_dict_key_1;
151     PyObject *tmp_dict_key_2;
152     PyObject *tmp_dict_key_3;
153     PyObject *tmp_dict_key_4;
154     PyObject *tmp_dict_value_1;
155     PyObject *tmp_dict_value_2;
156     PyObject *tmp_dict_value_3;
157     PyObject *tmp_dict_value_4;
158     int tmp_res;
159     PyObject *tmp_return_value; 149     PyObject *tmp_return_value;
160     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 150     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
161     static struct Nuitka_FrameObject *cache_frame_c7795c9a80381fec0c494225b4954f08 = NULL; 151     static struct Nuitka_FrameObject *cache_frame_c7795c9a80381fec0c494225b4954f08 = NULL;
162 152
163     struct Nuitka_FrameObject *frame_c7795c9a80381fec0c494225b4954f08; 153     struct Nuitka_FrameObject *frame_c7795c9a80381fec0c494225b4954f08;
193         exception_tb = NULL; 183         exception_tb = NULL;
194         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 184         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
195         CHAIN_EXCEPTION( exception_value ); 185         CHAIN_EXCEPTION( exception_value );
196 186
197         exception_lineno = 25; 187         exception_lineno = 25;
n 198         type_description_1 = "o"; n 188         type_description_1 = "N";
199         goto frame_exception_exit_1; 189         goto frame_exception_exit_1;
200     } 190     }
n 201   n
202     tmp_assign_source_1 = _PyDict_NewPresized( 4 );
203     tmp_dict_key_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key1 );
204  
205     if (unlikely( tmp_dict_key_1 == NULL ))
206     {
207         tmp_dict_key_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key1 );
208     }
209  
210     if ( tmp_dict_key_1 == NULL )
211     {
212         Py_DECREF( tmp_assign_source_1 );
213         exception_type = PyExc_NameError;
214         Py_INCREF( exception_type );
215         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key1" );
216         exception_tb = NULL;
217         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
218         CHAIN_EXCEPTION( exception_value );
219  
220         exception_lineno = 29;
221         type_description_1 = "o";
222         goto frame_exception_exit_1;
223     }
224  
225     tmp_dict_value_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
226  
227     if (unlikely( tmp_dict_value_1 == NULL ))
228     {
229         tmp_dict_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
230     }
231  
232     if ( tmp_dict_value_1 == NULL )
233     {
234         Py_DECREF( tmp_assign_source_1 );
235         exception_type = PyExc_NameError;
236         Py_INCREF( exception_type );
237         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
238         exception_tb = NULL;
239         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
240         CHAIN_EXCEPTION( exception_value );
241  
242         exception_lineno = 29;
243         type_description_1 = "o";
244         goto frame_exception_exit_1;
245     }
246  
247     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_1, tmp_dict_value_1 );
248     if ( tmp_res != 0 )
249     {
250         assert( ERROR_OCCURRED() );
251  
252         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
253         Py_DECREF( tmp_assign_source_1 );
254  
255         exception_lineno = 28;
256         type_description_1 = "o";
257         goto frame_exception_exit_1;
258     }
259     tmp_dict_key_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key2 );
260  
261     if (unlikely( tmp_dict_key_2 == NULL ))
262     {
263         tmp_dict_key_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key2 );
264     }
265  
266     if ( tmp_dict_key_2 == NULL )
267     {
268         Py_DECREF( tmp_assign_source_1 );
269         exception_type = PyExc_NameError;
270         Py_INCREF( exception_type );
271         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key2" );
272         exception_tb = NULL;
273         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
274         CHAIN_EXCEPTION( exception_value );
275  
276         exception_lineno = 30;
277         type_description_1 = "o";
278         goto frame_exception_exit_1;
279     }
280  
281     tmp_dict_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value2 );
282  
283     if (unlikely( tmp_dict_value_2 == NULL ))
284     {
285         tmp_dict_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value2 );
286     }
287  
288     if ( tmp_dict_value_2 == NULL )
289     {
290         Py_DECREF( tmp_assign_source_1 );
291         exception_type = PyExc_NameError;
292         Py_INCREF( exception_type );
293         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value2" );
294         exception_tb = NULL;
295         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
296         CHAIN_EXCEPTION( exception_value );
297  
298         exception_lineno = 30;
299         type_description_1 = "o";
300         goto frame_exception_exit_1;
301     }
302  
303     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_2, tmp_dict_value_2 );
304     if ( tmp_res != 0 )
305     {
306         assert( ERROR_OCCURRED() );
307  
308         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
309         Py_DECREF( tmp_assign_source_1 );
310  
311         exception_lineno = 28;
312         type_description_1 = "o";
313         goto frame_exception_exit_1;
314     }
315     tmp_dict_key_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key3 );
316  
317     if (unlikely( tmp_dict_key_3 == NULL ))
318     {
319         tmp_dict_key_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key3 );
320     }
321  
322     if ( tmp_dict_key_3 == NULL )
323     {
324         Py_DECREF( tmp_assign_source_1 );
325         exception_type = PyExc_NameError;
326         Py_INCREF( exception_type );
327         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key3" );
328         exception_tb = NULL;
329         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
330         CHAIN_EXCEPTION( exception_value );
331  
332         exception_lineno = 31;
333         type_description_1 = "o";
334         goto frame_exception_exit_1;
335     }
336  
337     tmp_dict_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value3 );
338  
339     if (unlikely( tmp_dict_value_3 == NULL ))
340     {
341         tmp_dict_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value3 );
342     }
343  
344     if ( tmp_dict_value_3 == NULL )
345     {
346         Py_DECREF( tmp_assign_source_1 );
347         exception_type = PyExc_NameError;
348         Py_INCREF( exception_type );
349         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value3" );
350         exception_tb = NULL;
351         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
352         CHAIN_EXCEPTION( exception_value );
353  
354         exception_lineno = 31;
355         type_description_1 = "o";
356         goto frame_exception_exit_1;
357     }
358  
359     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_3, tmp_dict_value_3 );
360     if ( tmp_res != 0 )
361     {
362         assert( ERROR_OCCURRED() );
363  
364         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
365         Py_DECREF( tmp_assign_source_1 );
366  
367         exception_lineno = 28;
368         type_description_1 = "o";
369         goto frame_exception_exit_1;
370     }
371     tmp_dict_key_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_key4 );
372  
373     if (unlikely( tmp_dict_key_4 == NULL ))
374     {
375         tmp_dict_key_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_key4 );
376     }
377  
378     if ( tmp_dict_key_4 == NULL )
379     {
380         Py_DECREF( tmp_assign_source_1 );
381         exception_type = PyExc_NameError;
382         Py_INCREF( exception_type );
383         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_key4" );
384         exception_tb = NULL;
385         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
386         CHAIN_EXCEPTION( exception_value );
387  
388         exception_lineno = 32;
389         type_description_1 = "o";
390         goto frame_exception_exit_1;
391     }
392  
393     tmp_dict_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value4 );
394  
395     if (unlikely( tmp_dict_value_4 == NULL ))
396     {
397         tmp_dict_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value4 );
398     }
399  
400     if ( tmp_dict_value_4 == NULL )
401     {
402         Py_DECREF( tmp_assign_source_1 );
403         exception_type = PyExc_NameError;
404         Py_INCREF( exception_type );
405         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value4" );
406         exception_tb = NULL;
407         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
408         CHAIN_EXCEPTION( exception_value );
409  
410         exception_lineno = 32;
411         type_description_1 = "o";
412         goto frame_exception_exit_1;
413     }
414  
415     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_4, tmp_dict_value_4 );
416     if ( tmp_res != 0 )
417     {
418         assert( ERROR_OCCURRED() );
419  
420         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
421         Py_DECREF( tmp_assign_source_1 );
422  
423         exception_lineno = 28;
424         type_description_1 = "o";
425         goto frame_exception_exit_1;
426     }
427     assert( var_l == NULL );
428     var_l = tmp_assign_source_1;
429 191
430 192
431 #if 0 193 #if 0
432     RESTORE_FRAME_EXCEPTION( frame_c7795c9a80381fec0c494225b4954f08 ); 194     RESTORE_FRAME_EXCEPTION( frame_c7795c9a80381fec0c494225b4954f08 );
433 #endif 195 #endif
454 216
455     // Attachs locals to frame if any. 217     // Attachs locals to frame if any.
456     Nuitka_Frame_AttachLocals( 218     Nuitka_Frame_AttachLocals(
457         (struct Nuitka_FrameObject *)frame_c7795c9a80381fec0c494225b4954f08, 219         (struct Nuitka_FrameObject *)frame_c7795c9a80381fec0c494225b4954f08,
458         type_description_1, 220         type_description_1,
n 459         var_l n 221         NULL
460     ); 222     );
461 223
462 224
463     // Release cached frame. 225     // Release cached frame.
464     if ( frame_c7795c9a80381fec0c494225b4954f08 == cache_frame_c7795c9a80381fec0c494225b4954f08 ) 226     if ( frame_c7795c9a80381fec0c494225b4954f08 == cache_frame_c7795c9a80381fec0c494225b4954f08 )
475     // Return the error. 237     // Return the error.
476     goto try_except_handler_1; 238     goto try_except_handler_1;
477 239
478     frame_no_exception_1:; 240     frame_no_exception_1:;
479 241
n 480     tmp_return_value = var_l; n
481  
482     CHECK_OBJECT( tmp_return_value );
483     Py_INCREF( tmp_return_value );
484     goto try_return_handler_1; 242     goto try_end_1;
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     CHECK_OBJECT( (PyObject *)var_l );
491     Py_DECREF( var_l );
492     var_l = NULL;
493  
494     goto function_return_exit;
495     // Exception handler code: 243     // Exception handler code:
496     try_except_handler_1:; 244     try_except_handler_1:;
497     exception_keeper_type_1 = exception_type; 245     exception_keeper_type_1 = exception_type;
498     exception_keeper_value_1 = exception_value; 246     exception_keeper_value_1 = exception_value;
499     exception_keeper_tb_1 = exception_tb; 247     exception_keeper_tb_1 = exception_tb;
509     exception_tb = exception_keeper_tb_1; 257     exception_tb = exception_keeper_tb_1;
510     exception_lineno = exception_keeper_lineno_1; 258     exception_lineno = exception_keeper_lineno_1;
511 259
512     goto function_exception_exit; 260     goto function_exception_exit;
513     // End of try: 261     // End of try:
t t 262     try_end_1:;
263     tmp_return_value = const_int_pos_1;
264     Py_INCREF( tmp_return_value );
265     goto function_return_exit;
514 266
515     // Return statement must have exited already. 267     // Return statement must have exited already.
516     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 268     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
517     return NULL; 269     return NULL;
518 270