Construct SetCreation

Performance Diagrams

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