Construct DictCreation

Performance Diagrams

Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)9331850373.61538461538461257.0CPython 2.759801196196.30769230769232345.75669823568563Nuitka (historic)59900989319.0000000000001345.49243782875516Nuitka (master)59950425441.69230769230774345.3615270687117Nuitka (develop)59901337564.3846153846155345.4915162949641Nuitka (factory)Construct DictCreationTicks Construct DictCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)12871431972.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)83505476316.0343.7953209305449Nuitka (master)83495467437.53846153846143343.8145369579755Nuitka (develop)83400504559.0769230769231343.99685403389645Nuitka (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     int tmp_res;
139     PyObject *tmp_return_value; 126     PyObject *tmp_return_value;
140     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 127     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
141     static struct Nuitka_FrameObject *cache_frame_function = NULL; 128     static struct Nuitka_FrameObject *cache_frame_function = NULL;
142 129
143     struct Nuitka_FrameObject *frame_function; 130     struct Nuitka_FrameObject *frame_function;
145     char const *type_description; 132     char const *type_description;
146     tmp_return_value = NULL; 133     tmp_return_value = NULL;
147 134
148     // Actual function code. 135     // Actual function code.
149     // Tried code: 136     // Tried code:
n 150     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_8032425c154ea482fb69955b718e6031, module___main__, sizeof(PyObject *) ); n 137     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_8032425c154ea482fb69955b718e6031, module___main__, sizeof(void *) );
151     frame_function = cache_frame_function; 138     frame_function = cache_frame_function;
152 139
153     // Push the new frame as the currently active one. 140     // Push the new frame as the currently active one.
154     pushFrameStack( frame_function ); 141     pushFrameStack( frame_function );
155 142
173         exception_tb = NULL; 160         exception_tb = NULL;
174         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 161         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
175         CHAIN_EXCEPTION( exception_value ); 162         CHAIN_EXCEPTION( exception_value );
176 163
177         exception_lineno = 24; 164         exception_lineno = 24;
n 178         type_description = "o"; n 165         type_description = "N";
179         goto frame_exception_exit_1; 166         goto frame_exception_exit_1;
180     } 167     }
n 181   n
182     tmp_assign_source_1 = _PyDict_NewPresized( 5 );
183     tmp_dict_key_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
184  
185     if (unlikely( tmp_dict_key_1 == NULL ))
186     {
187         tmp_dict_key_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
188     }
189  
190     if ( tmp_dict_key_1 == NULL )
191     {
192         Py_DECREF( tmp_assign_source_1 );
193         exception_type = PyExc_NameError;
194         Py_INCREF( exception_type );
195         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
196         exception_tb = NULL;
197         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
198         CHAIN_EXCEPTION( exception_value );
199  
200         exception_lineno = 28;
201         type_description = "o";
202         goto frame_exception_exit_1;
203     }
204  
205     tmp_dict_value_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
206  
207     if (unlikely( tmp_dict_value_1 == NULL ))
208     {
209         tmp_dict_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
210     }
211  
212     if ( tmp_dict_value_1 == NULL )
213     {
214         Py_DECREF( tmp_assign_source_1 );
215         exception_type = PyExc_NameError;
216         Py_INCREF( exception_type );
217         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
218         exception_tb = NULL;
219         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
220         CHAIN_EXCEPTION( exception_value );
221  
222         exception_lineno = 28;
223         type_description = "o";
224         goto frame_exception_exit_1;
225     }
226  
227     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_1, tmp_dict_value_1 );
228     if ( tmp_res != 0 )
229     {
230         assert( ERROR_OCCURRED() );
231  
232         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
233         Py_DECREF( tmp_assign_source_1 );
234  
235         exception_lineno = 27;
236         type_description = "o";
237         goto frame_exception_exit_1;
238     }
239     tmp_dict_key_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
240  
241     if (unlikely( tmp_dict_key_2 == NULL ))
242     {
243         tmp_dict_key_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
244     }
245  
246     if ( tmp_dict_key_2 == NULL )
247     {
248         Py_DECREF( tmp_assign_source_1 );
249         exception_type = PyExc_NameError;
250         Py_INCREF( exception_type );
251         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
252         exception_tb = NULL;
253         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
254         CHAIN_EXCEPTION( exception_value );
255  
256         exception_lineno = 29;
257         type_description = "o";
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         type_description = "o";
280         goto frame_exception_exit_1;
281     }
282  
283     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_2, tmp_dict_value_2 );
284     if ( tmp_res != 0 )
285     {
286         assert( ERROR_OCCURRED() );
287  
288         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
289         Py_DECREF( tmp_assign_source_1 );
290  
291         exception_lineno = 27;
292         type_description = "o";
293         goto frame_exception_exit_1;
294     }
295     tmp_dict_key_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
296  
297     if (unlikely( tmp_dict_key_3 == NULL ))
298     {
299         tmp_dict_key_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
300     }
301  
302     if ( tmp_dict_key_3 == NULL )
303     {
304         Py_DECREF( tmp_assign_source_1 );
305         exception_type = PyExc_NameError;
306         Py_INCREF( exception_type );
307         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
308         exception_tb = NULL;
309         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
310         CHAIN_EXCEPTION( exception_value );
311  
312         exception_lineno = 30;
313         type_description = "o";
314         goto frame_exception_exit_1;
315     }
316  
317     tmp_dict_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
318  
319     if (unlikely( tmp_dict_value_3 == NULL ))
320     {
321         tmp_dict_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
322     }
323  
324     if ( tmp_dict_value_3 == NULL )
325     {
326         Py_DECREF( tmp_assign_source_1 );
327         exception_type = PyExc_NameError;
328         Py_INCREF( exception_type );
329         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
330         exception_tb = NULL;
331         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
332         CHAIN_EXCEPTION( exception_value );
333  
334         exception_lineno = 30;
335         type_description = "o";
336         goto frame_exception_exit_1;
337     }
338  
339     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_3, tmp_dict_value_3 );
340     if ( tmp_res != 0 )
341     {
342         assert( ERROR_OCCURRED() );
343  
344         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
345         Py_DECREF( tmp_assign_source_1 );
346  
347         exception_lineno = 27;
348         type_description = "o";
349         goto frame_exception_exit_1;
350     }
351     tmp_dict_key_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
352  
353     if (unlikely( tmp_dict_key_4 == NULL ))
354     {
355         tmp_dict_key_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
356     }
357  
358     if ( tmp_dict_key_4 == NULL )
359     {
360         Py_DECREF( tmp_assign_source_1 );
361         exception_type = PyExc_NameError;
362         Py_INCREF( exception_type );
363         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
364         exception_tb = NULL;
365         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
366         CHAIN_EXCEPTION( exception_value );
367  
368         exception_lineno = 31;
369         type_description = "o";
370         goto frame_exception_exit_1;
371     }
372  
373     tmp_dict_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
374  
375     if (unlikely( tmp_dict_value_4 == NULL ))
376     {
377         tmp_dict_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
378     }
379  
380     if ( tmp_dict_value_4 == NULL )
381     {
382         Py_DECREF( tmp_assign_source_1 );
383         exception_type = PyExc_NameError;
384         Py_INCREF( exception_type );
385         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
386         exception_tb = NULL;
387         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
388         CHAIN_EXCEPTION( exception_value );
389  
390         exception_lineno = 31;
391         type_description = "o";
392         goto frame_exception_exit_1;
393     }
394  
395     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_4, tmp_dict_value_4 );
396     if ( tmp_res != 0 )
397     {
398         assert( ERROR_OCCURRED() );
399  
400         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
401         Py_DECREF( tmp_assign_source_1 );
402  
403         exception_lineno = 27;
404         type_description = "o";
405         goto frame_exception_exit_1;
406     }
407     tmp_dict_key_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
408  
409     if (unlikely( tmp_dict_key_5 == NULL ))
410     {
411         tmp_dict_key_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
412     }
413  
414     if ( tmp_dict_key_5 == NULL )
415     {
416         Py_DECREF( tmp_assign_source_1 );
417         exception_type = PyExc_NameError;
418         Py_INCREF( exception_type );
419         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
420         exception_tb = NULL;
421         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
422         CHAIN_EXCEPTION( exception_value );
423  
424         exception_lineno = 32;
425         type_description = "o";
426         goto frame_exception_exit_1;
427     }
428  
429     tmp_dict_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
430  
431     if (unlikely( tmp_dict_value_5 == NULL ))
432     {
433         tmp_dict_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
434     }
435  
436     if ( tmp_dict_value_5 == NULL )
437     {
438         Py_DECREF( tmp_assign_source_1 );
439         exception_type = PyExc_NameError;
440         Py_INCREF( exception_type );
441         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
442         exception_tb = NULL;
443         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
444         CHAIN_EXCEPTION( exception_value );
445  
446         exception_lineno = 32;
447         type_description = "o";
448         goto frame_exception_exit_1;
449     }
450  
451     tmp_res = PyDict_SetItem( tmp_assign_source_1, tmp_dict_key_5, tmp_dict_value_5 );
452     if ( tmp_res != 0 )
453     {
454         assert( ERROR_OCCURRED() );
455  
456         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
457         Py_DECREF( tmp_assign_source_1 );
458  
459         exception_lineno = 27;
460         type_description = "o";
461         goto frame_exception_exit_1;
462     }
463     assert( var_l == NULL );
464     var_l = tmp_assign_source_1;
465 168
466 169
467 #if 0 170 #if 0
468     RESTORE_FRAME_EXCEPTION( frame_function ); 171     RESTORE_FRAME_EXCEPTION( frame_function );
469 #endif 172 #endif
486     else if ( exception_tb->tb_frame != &frame_function->m_frame ) 189     else if ( exception_tb->tb_frame != &frame_function->m_frame )
487     { 190     {
488         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno ); 191         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
489     } 192     }
490 193
n 491     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,var_l ); n 194     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,NULL );
492 195
493     // Release cached frame. 196     // Release cached frame.
494     if ( frame_function == cache_frame_function ) 197     if ( frame_function == cache_frame_function )
495     { 198     {
496         Py_DECREF( frame_function ); 199         Py_DECREF( frame_function );
506     // Return the error. 209     // Return the error.
507     goto try_except_handler_1; 210     goto try_except_handler_1;
508 211
509     frame_no_exception_1:; 212     frame_no_exception_1:;
510 213
n 511     tmp_return_value = var_l; n
512  
513     Py_INCREF( tmp_return_value );
514     goto try_return_handler_1; 214     goto try_end_1;
515     // tried codes exits in all cases
516     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
517     return NULL;
518     // Return handler code:
519     try_return_handler_1:;
520     CHECK_OBJECT( (PyObject *)var_l );
521     Py_DECREF( var_l );
522     var_l = NULL;
523  
524     goto function_return_exit;
525     // Exception handler code: 215     // Exception handler code:
526     try_except_handler_1:; 216     try_except_handler_1:;
527     exception_keeper_type_1 = exception_type; 217     exception_keeper_type_1 = exception_type;
528     exception_keeper_value_1 = exception_value; 218     exception_keeper_value_1 = exception_value;
529     exception_keeper_tb_1 = exception_tb; 219     exception_keeper_tb_1 = exception_tb;
539     exception_tb = exception_keeper_tb_1; 229     exception_tb = exception_keeper_tb_1;
540     exception_lineno = exception_keeper_lineno_1; 230     exception_lineno = exception_keeper_lineno_1;
541 231
542     goto function_exception_exit; 232     goto function_exception_exit;
543     // End of try: 233     // End of try:
t t 234     try_end_1:;
235     tmp_return_value = const_int_pos_1;
236     Py_INCREF( tmp_return_value );
237     goto function_return_exit;
544 238
545     // Return statement must have exited already. 239     // Return statement must have exited already.
546     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 240     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
547     return NULL; 241     return NULL;
548 242