Construct DictCreation

Performance Diagrams

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