Construct SetCreation

Performance Diagrams

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