Construct SetCreation

Performance Diagrams

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