Construct SetCreation

Performance Diagrams

Construct SetCreation 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)6357897388.95192307692307257.0CPython 2.746151970242.31730769230768324.73435218965335Nuitka (master)46151249395.6826923076923324.7371545342636Nuitka (develop)46151345549.0480769230769324.7367814065485Nuitka (factory)Construct SetCreationTicks Construct SetCreation 001000000010000000200000002000000030000000300000004000000040000000500000005000000060000000600000007000000070000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)7520138688.95192307692307257.0CPython 3.554155991242.31730769230768326.1561839007554Nuitka (master)54150610395.6826923076923326.1738661265141Nuitka (develop)54156094549.0480769230769326.1558454377832Nuitka (factory)Construct SetCreationTicks

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
    }
# construct_alternative


# construct_end

    return l

import itertools
for x in itertools.repeat(None, 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

import itertools
for x in itertools.repeat(None, 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,
29         module_value1,
30         module_value1,
31         module_value1,
32         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 import itertools 41 import itertools

Context Diff of Generated Code


Construct
Baseline
32 32
33 /* The declarations of module constants used, if any. */ 33 /* The declarations of module constants used, if any. */
34 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
35 static PyObject *const_tuple_str_plain_l_tuple; 35 static PyObject *const_tuple_str_plain_l_tuple;
36 static PyObject *const_str_digest_77beda99ebd16c5663833b97191df0c1; 36 static PyObject *const_str_digest_77beda99ebd16c5663833b97191df0c1;
n n 37 extern PyObject *const_int_pos_1;
37 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
38 extern PyObject *const_int_0; 39 extern PyObject *const_int_0;
39 extern PyObject *const_str_plain_print; 40 extern PyObject *const_str_plain_print;
40 static PyObject *const_int_pos_50000; 41 static PyObject *const_int_pos_50000;
41 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
119 #ifndef __NUITKA_NO_ASSERT__ 120 #ifndef __NUITKA_NO_ASSERT__
120     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 121     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
121 #endif 122 #endif
122 123
123     // Local variable declarations. 124     // Local variable declarations.
n 124     PyObject *var_l = NULL; n
125     struct Nuitka_FrameObject *frame_dfc33bcc1733f0635c39c46b644ec812; 125     struct Nuitka_FrameObject *frame_dfc33bcc1733f0635c39c46b644ec812;
126     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 126     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
127     PyObject *exception_type = NULL; 127     PyObject *exception_type = NULL;
128     PyObject *exception_value = NULL; 128     PyObject *exception_value = NULL;
129     PyTracebackObject *exception_tb = NULL; 129     PyTracebackObject *exception_tb = NULL;
130     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 130     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 131     int tmp_res; n
132     static struct Nuitka_FrameObject *cache_frame_dfc33bcc1733f0635c39c46b644ec812 = NULL; 131     static struct Nuitka_FrameObject *cache_frame_dfc33bcc1733f0635c39c46b644ec812 = NULL;
133     PyObject *tmp_return_value = NULL; 132     PyObject *tmp_return_value = NULL;
n 134     PyObject *exception_keeper_type_1; n
135     PyObject *exception_keeper_value_1;
136     PyTracebackObject *exception_keeper_tb_1;
137     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
138 133
139     // Actual function body. 134     // Actual function body.
n 140     // Tried code: n
141     MAKE_OR_REUSE_FRAME( cache_frame_dfc33bcc1733f0635c39c46b644ec812, codeobj_dfc33bcc1733f0635c39c46b644ec812, module___main__, sizeof(void *) ); 135     MAKE_OR_REUSE_FRAME( cache_frame_dfc33bcc1733f0635c39c46b644ec812, codeobj_dfc33bcc1733f0635c39c46b644ec812, module___main__, sizeof(void *) );
142     frame_dfc33bcc1733f0635c39c46b644ec812 = cache_frame_dfc33bcc1733f0635c39c46b644ec812; 136     frame_dfc33bcc1733f0635c39c46b644ec812 = cache_frame_dfc33bcc1733f0635c39c46b644ec812;
143 137
144     // Push the new frame as the currently active one. 138     // Push the new frame as the currently active one.
145     pushFrameStack( frame_dfc33bcc1733f0635c39c46b644ec812 ); 139     pushFrameStack( frame_dfc33bcc1733f0635c39c46b644ec812 );
166             exception_tb = NULL; 160             exception_tb = NULL;
167             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 161             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
168             CHAIN_EXCEPTION( exception_value ); 162             CHAIN_EXCEPTION( exception_value );
169 163
170             exception_lineno = 24; 164             exception_lineno = 24;
n 171             type_description_1 = "o"; n 165             type_description_1 = "N";
172             goto frame_exception_exit_1; 166             goto frame_exception_exit_1;
173         } 167         }
174 168
n 175     } n
176     {
177         PyObject *tmp_assign_source_1;
178         PyObject *tmp_set_element_1;
179         PyObject *tmp_mvar_value_2;
180         PyObject *tmp_mvar_value_3;
181         PyObject *tmp_mvar_value_4;
182         PyObject *tmp_mvar_value_5;
183         PyObject *tmp_mvar_value_6;
184         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
185  
186         if (unlikely( tmp_mvar_value_2 == NULL ))
187         {
188             tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
189         }
190  
191         if ( tmp_mvar_value_2 == NULL )
192         {
193  
194             exception_type = PyExc_NameError;
195             Py_INCREF( exception_type );
196             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
197             exception_tb = NULL;
198             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
199             CHAIN_EXCEPTION( exception_value );
200  
201             exception_lineno = 28;
202             type_description_1 = "o";
203             goto frame_exception_exit_1;
204         }
205  
206         tmp_set_element_1 = tmp_mvar_value_2;
207         tmp_assign_source_1 = PySet_New( NULL );
208         assert( tmp_assign_source_1 );
209         tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1 );
210         if ( tmp_res != 0 )
211         {
212             assert( ERROR_OCCURRED() );
213  
214             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
215             Py_DECREF( tmp_assign_source_1 );
216  
217             exception_lineno = 27;
218             type_description_1 = "o";
219             goto frame_exception_exit_1;
220         }
221         tmp_mvar_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
222  
223         if (unlikely( tmp_mvar_value_3 == NULL ))
224         {
225             tmp_mvar_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
226         }
227  
228         if ( tmp_mvar_value_3 == NULL )
229         {
230             Py_DECREF( tmp_assign_source_1 );
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_set_element_1 = tmp_mvar_value_3;
244         tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_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 = 27;
253             type_description_1 = "o";
254             goto frame_exception_exit_1;
255         }
256         tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
257  
258         if (unlikely( tmp_mvar_value_4 == NULL ))
259         {
260             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
261         }
262  
263         if ( tmp_mvar_value_4 == 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_value1" );
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_set_element_1 = tmp_mvar_value_4;
279         tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1 );
280         if ( tmp_res != 0 )
281         {
282             assert( ERROR_OCCURRED() );
283  
284             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
285             Py_DECREF( tmp_assign_source_1 );
286  
287             exception_lineno = 27;
288             type_description_1 = "o";
289             goto frame_exception_exit_1;
290         }
291         tmp_mvar_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
292  
293         if (unlikely( tmp_mvar_value_5 == NULL ))
294         {
295             tmp_mvar_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
296         }
297  
298         if ( tmp_mvar_value_5 == NULL )
299         {
300             Py_DECREF( tmp_assign_source_1 );
301             exception_type = PyExc_NameError;
302             Py_INCREF( exception_type );
303             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
304             exception_tb = NULL;
305             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
306             CHAIN_EXCEPTION( exception_value );
307  
308             exception_lineno = 31;
309             type_description_1 = "o";
310             goto frame_exception_exit_1;
311         }
312  
313         tmp_set_element_1 = tmp_mvar_value_5;
314         tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1 );
315         if ( tmp_res != 0 )
316         {
317             assert( ERROR_OCCURRED() );
318  
319             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
320             Py_DECREF( tmp_assign_source_1 );
321  
322             exception_lineno = 27;
323             type_description_1 = "o";
324             goto frame_exception_exit_1;
325         }
326         tmp_mvar_value_6 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
327  
328         if (unlikely( tmp_mvar_value_6 == NULL ))
329         {
330             tmp_mvar_value_6 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
331         }
332  
333         if ( tmp_mvar_value_6 == NULL )
334         {
335             Py_DECREF( tmp_assign_source_1 );
336             exception_type = PyExc_NameError;
337             Py_INCREF( exception_type );
338             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
339             exception_tb = NULL;
340             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
341             CHAIN_EXCEPTION( exception_value );
342  
343             exception_lineno = 32;
344             type_description_1 = "o";
345             goto frame_exception_exit_1;
346         }
347  
348         tmp_set_element_1 = tmp_mvar_value_6;
349         tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1 );
350         if ( tmp_res != 0 )
351         {
352             assert( ERROR_OCCURRED() );
353  
354             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
355             Py_DECREF( tmp_assign_source_1 );
356  
357             exception_lineno = 27;
358             type_description_1 = "o";
359             goto frame_exception_exit_1;
360         }
361         assert( var_l == NULL );
362         var_l = tmp_assign_source_1;
363     } 169     }
364 170
365 #if 0 171 #if 0
366     RESTORE_FRAME_EXCEPTION( frame_dfc33bcc1733f0635c39c46b644ec812 ); 172     RESTORE_FRAME_EXCEPTION( frame_dfc33bcc1733f0635c39c46b644ec812 );
367 #endif 173 #endif
388 194
389     // Attachs locals to frame if any. 195     // Attachs locals to frame if any.
390     Nuitka_Frame_AttachLocals( 196     Nuitka_Frame_AttachLocals(
391         (struct Nuitka_FrameObject *)frame_dfc33bcc1733f0635c39c46b644ec812, 197         (struct Nuitka_FrameObject *)frame_dfc33bcc1733f0635c39c46b644ec812,
392         type_description_1, 198         type_description_1,
n 393         var_l n 199         NULL
394     ); 200     );
395 201
396 202
397     // Release cached frame. 203     // Release cached frame.
398     if ( frame_dfc33bcc1733f0635c39c46b644ec812 == cache_frame_dfc33bcc1733f0635c39c46b644ec812 ) 204     if ( frame_dfc33bcc1733f0635c39c46b644ec812 == cache_frame_dfc33bcc1733f0635c39c46b644ec812 )
405 211
406     // Put the previous frame back on top. 212     // Put the previous frame back on top.
407     popFrameStack(); 213     popFrameStack();
408 214
409     // Return the error. 215     // Return the error.
n 410     goto try_except_handler_1; n 216     goto function_exception_exit;
411 217
412     frame_no_exception_1:; 218     frame_no_exception_1:;
n 413     CHECK_OBJECT( var_l ); n 219     tmp_return_value = const_int_pos_1;
414     tmp_return_value = var_l;
415     Py_INCREF( tmp_return_value ); 220     Py_INCREF( tmp_return_value );
n 416     goto try_return_handler_1; n
417     // tried codes exits in all cases
418     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
419     return NULL;
420     // Return handler code:
421     try_return_handler_1:;
422     CHECK_OBJECT( (PyObject *)var_l );
423     Py_DECREF( var_l );
424     var_l = NULL;
425  
426     goto function_return_exit; 221     goto function_return_exit;
t 427     // Exception handler code: t
428     try_except_handler_1:;
429     exception_keeper_type_1 = exception_type;
430     exception_keeper_value_1 = exception_value;
431     exception_keeper_tb_1 = exception_tb;
432     exception_keeper_lineno_1 = exception_lineno;
433     exception_type = NULL;
434     exception_value = NULL;
435     exception_tb = NULL;
436     exception_lineno = 0;
437  
438     // Re-raise.
439     exception_type = exception_keeper_type_1;
440     exception_value = exception_keeper_value_1;
441     exception_tb = exception_keeper_tb_1;
442     exception_lineno = exception_keeper_lineno_1;
443  
444     goto function_exception_exit;
445     // End of try:
446 222
447     // Return statement must have exited already. 223     // Return statement must have exited already.
448     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 224     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
449     return NULL; 225     return NULL;
450 226