Construct DictCreation

Performance Diagrams

Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)9331850373.61538461538461257.0CPython 2.759801196196.30769230769232345.75669823568563Nuitka (historic)59949354319.0000000000001345.36436316839627Nuitka (master)59900887441.69230769230774345.49270793348705Nuitka (develop)59900893564.3846153846155345.4926920449734Nuitka (factory)Construct DictCreationTicks Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)12871431972.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)83499414316.0343.8069592119201Nuitka (master)83502172437.53846153846143343.80166419706813Nuitka (develop)83502250559.0769230769231343.8015144468294Nuitka (factory)Construct DictCreationTicks

Source Code with Construct

module_value1 = 1000

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

# construct_begin
    l = {
        module_value1 : module_value1,
        module_value1 : module_value1,
        module_value1 : module_value1,
        module_value1 : module_value1,
        module_value1 : module_value1
    }
# construct_alternative


# construct_end

    return l

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000

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

# construct_begin







# construct_alternative
    l = 1
# construct_end
# construct_end

    return l

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
22 def calledRepeatedly(): 22 def calledRepeatedly():
23     # Force frame and eliminate forward propagation (currently). 23     # Force frame and eliminate forward propagation (currently).
24     module_value1 24     module_value1
25 25
26 # construct_begin 26 # construct_begin
n 27     l = { n
28         module_value1 : module_value1,
29         module_value1 : module_value1,
30         module_value1 : module_value1,
31         module_value1 : module_value1,
32         module_value1 : module_value1
33     }
34 # construct_alternative
35 27
36 28
t t 29  
30  
31  
32  
33  
34 # construct_alternative
35     l = 1
36 # construct_end
37 # construct_end 37 # construct_end
38 38
39     return l 39     return l
40 40
41 for x in xrange(50000): 41 for x in xrange(50000):

Context Diff of Generated Code


Construct
Baseline
114 #ifndef __NUITKA_NO_ASSERT__ 114 #ifndef __NUITKA_NO_ASSERT__
115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
116 #endif 116 #endif
117 117
118     // Local variable declarations. 118     // Local variable declarations.
n 119     PyObject *var_l = NULL; n
120     PyObject *exception_type = NULL, *exception_value = NULL; 119     PyObject *exception_type = NULL, *exception_value = NULL;
121     PyTracebackObject *exception_tb = NULL; 120     PyTracebackObject *exception_tb = NULL;
122     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 121     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
123     PyObject *exception_keeper_type_1; 122     PyObject *exception_keeper_type_1;
124     PyObject *exception_keeper_value_1; 123     PyObject *exception_keeper_value_1;
125     PyTracebackObject *exception_keeper_tb_1; 124     PyTracebackObject *exception_keeper_tb_1;
126     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 125     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 127     PyObject *tmp_assign_source_1; n
128     PyObject *tmp_dict_key_1;
129     PyObject *tmp_dict_key_2;
130     PyObject *tmp_dict_key_3;
131     PyObject *tmp_dict_key_4;
132     PyObject *tmp_dict_key_5;
133     PyObject *tmp_dict_value_1;
134     PyObject *tmp_dict_value_2;
135     PyObject *tmp_dict_value_3;
136     PyObject *tmp_dict_value_4;
137     PyObject *tmp_dict_value_5;
138     PyObject *tmp_frame_locals; 126     PyObject *tmp_frame_locals;
n 139     int tmp_res; n
140     PyObject *tmp_return_value; 127     PyObject *tmp_return_value;
141     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 128     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
142     static PyFrameObject *cache_frame_function = NULL; 129     static PyFrameObject *cache_frame_function = NULL;
143 130
144     PyFrameObject *frame_function; 131     PyFrameObject *frame_function;
180         CHAIN_EXCEPTION( exception_value ); 167         CHAIN_EXCEPTION( exception_value );
181 168
182         exception_lineno = 24; 169         exception_lineno = 24;
183         goto frame_exception_exit_1; 170         goto frame_exception_exit_1;
184     } 171     }
n 185   n
186     tmp_assign_source_1 = _PyDict_NewPresized( 5 );
187     tmp_dict_key_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
188  
189     if (unlikely( tmp_dict_key_1 == NULL ))
190     {
191         tmp_dict_key_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
192     }
193  
194     if ( tmp_dict_key_1 == NULL )
195     {
196         Py_DECREF( tmp_assign_source_1 );
197         exception_type = PyExc_NameError;
198         Py_INCREF( exception_type );
199         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
200         exception_tb = NULL;
201         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
202         CHAIN_EXCEPTION( exception_value );
203  
204         exception_lineno = 28;
205         goto frame_exception_exit_1;
206     }
207  
208     tmp_dict_value_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
209  
210     if (unlikely( tmp_dict_value_1 == NULL ))
211     {
212         tmp_dict_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
213     }
214  
215     if ( tmp_dict_value_1 == NULL )
216     {
217         Py_DECREF( tmp_assign_source_1 );
218         exception_type = PyExc_NameError;
219         Py_INCREF( exception_type );
220         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
221         exception_tb = NULL;
222         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
223         CHAIN_EXCEPTION( exception_value );
224  
225         exception_lineno = 28;
226         goto frame_exception_exit_1;
227     }
228  
229     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_1, tmp_dict_value_1 );
230     if ( tmp_res != 0 )
231     {
232         assert( ERROR_OCCURRED() );
233  
234         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
235         Py_DECREF( tmp_assign_source_1 );
236  
237         exception_lineno = 27;
238         goto frame_exception_exit_1;
239     }
240     tmp_dict_key_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
241  
242     if (unlikely( tmp_dict_key_2 == NULL ))
243     {
244         tmp_dict_key_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
245     }
246  
247     if ( tmp_dict_key_2 == NULL )
248     {
249         Py_DECREF( tmp_assign_source_1 );
250         exception_type = PyExc_NameError;
251         Py_INCREF( exception_type );
252         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
253         exception_tb = NULL;
254         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
255         CHAIN_EXCEPTION( exception_value );
256  
257         exception_lineno = 29;
258         goto frame_exception_exit_1;
259     }
260  
261     tmp_dict_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
262  
263     if (unlikely( tmp_dict_value_2 == NULL ))
264     {
265         tmp_dict_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
266     }
267  
268     if ( tmp_dict_value_2 == NULL )
269     {
270         Py_DECREF( tmp_assign_source_1 );
271         exception_type = PyExc_NameError;
272         Py_INCREF( exception_type );
273         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
274         exception_tb = NULL;
275         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
276         CHAIN_EXCEPTION( exception_value );
277  
278         exception_lineno = 29;
279         goto frame_exception_exit_1;
280     }
281  
282     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_2, tmp_dict_value_2 );
283     if ( tmp_res != 0 )
284     {
285         assert( ERROR_OCCURRED() );
286  
287         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
288         Py_DECREF( tmp_assign_source_1 );
289  
290         exception_lineno = 27;
291         goto frame_exception_exit_1;
292     }
293     tmp_dict_key_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
294  
295     if (unlikely( tmp_dict_key_3 == NULL ))
296     {
297         tmp_dict_key_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
298     }
299  
300     if ( tmp_dict_key_3 == NULL )
301     {
302         Py_DECREF( tmp_assign_source_1 );
303         exception_type = PyExc_NameError;
304         Py_INCREF( exception_type );
305         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
306         exception_tb = NULL;
307         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
308         CHAIN_EXCEPTION( exception_value );
309  
310         exception_lineno = 30;
311         goto frame_exception_exit_1;
312     }
313  
314     tmp_dict_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
315  
316     if (unlikely( tmp_dict_value_3 == NULL ))
317     {
318         tmp_dict_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
319     }
320  
321     if ( tmp_dict_value_3 == NULL )
322     {
323         Py_DECREF( tmp_assign_source_1 );
324         exception_type = PyExc_NameError;
325         Py_INCREF( exception_type );
326         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
327         exception_tb = NULL;
328         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
329         CHAIN_EXCEPTION( exception_value );
330  
331         exception_lineno = 30;
332         goto frame_exception_exit_1;
333     }
334  
335     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_3, tmp_dict_value_3 );
336     if ( tmp_res != 0 )
337     {
338         assert( ERROR_OCCURRED() );
339  
340         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
341         Py_DECREF( tmp_assign_source_1 );
342  
343         exception_lineno = 27;
344         goto frame_exception_exit_1;
345     }
346     tmp_dict_key_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
347  
348     if (unlikely( tmp_dict_key_4 == NULL ))
349     {
350         tmp_dict_key_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
351     }
352  
353     if ( tmp_dict_key_4 == NULL )
354     {
355         Py_DECREF( tmp_assign_source_1 );
356         exception_type = PyExc_NameError;
357         Py_INCREF( exception_type );
358         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
359         exception_tb = NULL;
360         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
361         CHAIN_EXCEPTION( exception_value );
362  
363         exception_lineno = 31;
364         goto frame_exception_exit_1;
365     }
366  
367     tmp_dict_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
368  
369     if (unlikely( tmp_dict_value_4 == NULL ))
370     {
371         tmp_dict_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
372     }
373  
374     if ( tmp_dict_value_4 == NULL )
375     {
376         Py_DECREF( tmp_assign_source_1 );
377         exception_type = PyExc_NameError;
378         Py_INCREF( exception_type );
379         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
380         exception_tb = NULL;
381         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
382         CHAIN_EXCEPTION( exception_value );
383  
384         exception_lineno = 31;
385         goto frame_exception_exit_1;
386     }
387  
388     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_4, tmp_dict_value_4 );
389     if ( tmp_res != 0 )
390     {
391         assert( ERROR_OCCURRED() );
392  
393         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
394         Py_DECREF( tmp_assign_source_1 );
395  
396         exception_lineno = 27;
397         goto frame_exception_exit_1;
398     }
399     tmp_dict_key_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
400  
401     if (unlikely( tmp_dict_key_5 == NULL ))
402     {
403         tmp_dict_key_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
404     }
405  
406     if ( tmp_dict_key_5 == NULL )
407     {
408         Py_DECREF( tmp_assign_source_1 );
409         exception_type = PyExc_NameError;
410         Py_INCREF( exception_type );
411         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
412         exception_tb = NULL;
413         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
414         CHAIN_EXCEPTION( exception_value );
415  
416         exception_lineno = 32;
417         goto frame_exception_exit_1;
418     }
419  
420     tmp_dict_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
421  
422     if (unlikely( tmp_dict_value_5 == NULL ))
423     {
424         tmp_dict_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
425     }
426  
427     if ( tmp_dict_value_5 == NULL )
428     {
429         Py_DECREF( tmp_assign_source_1 );
430         exception_type = PyExc_NameError;
431         Py_INCREF( exception_type );
432         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
433         exception_tb = NULL;
434         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
435         CHAIN_EXCEPTION( exception_value );
436  
437         exception_lineno = 32;
438         goto frame_exception_exit_1;
439     }
440  
441     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_5, tmp_dict_value_5 );
442     if ( tmp_res != 0 )
443     {
444         assert( ERROR_OCCURRED() );
445  
446         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
447         Py_DECREF( tmp_assign_source_1 );
448  
449         exception_lineno = 27;
450         goto frame_exception_exit_1;
451     }
452     assert( var_l == NULL );
453     var_l = tmp_assign_source_1;
454 172
455 173
456 #if 0 174 #if 0
457     RESTORE_FRAME_EXCEPTION( frame_function ); 175     RESTORE_FRAME_EXCEPTION( frame_function );
458 #endif 176 #endif
488 206
489         if (needs_detach) 207         if (needs_detach)
490         { 208         {
491 209
492             tmp_frame_locals = PyDict_New(); 210             tmp_frame_locals = PyDict_New();
n 493             if ( var_l ) n
494             {
495                 int res = PyDict_SetItem(
496                     tmp_frame_locals,
497                     const_str_plain_l,
498                     var_l
499                 );
500  
501                 assert( res == 0 );
502             }
503  
504 211
505 212
506             detachFrame( exception_tb, tmp_frame_locals ); 213             detachFrame( exception_tb, tmp_frame_locals );
507         } 214         }
508     } 215     }
517     // Return the error. 224     // Return the error.
518     goto try_except_handler_1; 225     goto try_except_handler_1;
519 226
520     frame_no_exception_1:; 227     frame_no_exception_1:;
521 228
n 522     tmp_return_value = var_l; n
523  
524     Py_INCREF( tmp_return_value );
525     goto try_return_handler_1; 229     goto try_end_1;
526     // tried codes exits in all cases
527     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
528     return NULL;
529     // Return handler code:
530     try_return_handler_1:;
531     CHECK_OBJECT( (PyObject *)var_l );
532     Py_DECREF( var_l );
533     var_l = NULL;
534  
535     goto function_return_exit;
536     // Exception handler code: 230     // Exception handler code:
537     try_except_handler_1:; 231     try_except_handler_1:;
538     exception_keeper_type_1 = exception_type; 232     exception_keeper_type_1 = exception_type;
539     exception_keeper_value_1 = exception_value; 233     exception_keeper_value_1 = exception_value;
540     exception_keeper_tb_1 = exception_tb; 234     exception_keeper_tb_1 = exception_tb;
550     exception_tb = exception_keeper_tb_1; 244     exception_tb = exception_keeper_tb_1;
551     exception_lineno = exception_keeper_lineno_1; 245     exception_lineno = exception_keeper_lineno_1;
552 246
553     goto function_exception_exit; 247     goto function_exception_exit;
554     // End of try: 248     // End of try:
t t 249     try_end_1:;
250     tmp_return_value = const_int_pos_1;
251     Py_INCREF( tmp_return_value );
252     goto function_return_exit;
555 253
556     // Return statement must have exited already. 254     // Return statement must have exited already.
557     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 255     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
558     return NULL; 256     return NULL;
559 257