Construct ListCreation

Performance Diagrams

Construct ListCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4508641488.95192307692307257.0CPython 2.729550252242.31730769230768342.15258383771493Nuitka (master)29551403395.6826923076923342.14627528969663Nuitka (develop)29551292549.0480769230769342.146883672694Nuitka (factory)Construct ListCreationTicks Construct ListCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)4945524788.95192307692307257.0CPython 3.533101144242.31730769230768338.71732420797764Nuitka (master)33100439395.6826923076923338.72084691500515Nuitka (develop)33101172549.0480769230769338.7171842990461Nuitka (factory)Construct ListCreationTicks

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



    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

    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 37
38     return l 38     return l
39 39
40 import itertools 40 import itertools
41 for x in itertools.repeat(None, 50000): 41 for x in itertools.repeat(None, 50000):

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;
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_2179f2a37c0248d9475f34a5db027876; 123     struct Nuitka_FrameObject *frame_2179f2a37c0248d9475f34a5db027876;
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;
129     static struct Nuitka_FrameObject *cache_frame_2179f2a37c0248d9475f34a5db027876 = NULL; 129     static struct Nuitka_FrameObject *cache_frame_2179f2a37c0248d9475f34a5db027876 = NULL;
130     PyObject *tmp_return_value = NULL; 130     PyObject *tmp_return_value = NULL;
n 131     PyObject *exception_keeper_type_1; n
132     PyObject *exception_keeper_value_1;
133     PyTracebackObject *exception_keeper_tb_1;
134     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
135 131
136     // Actual function body. 132     // Actual function body.
n 137     // Tried code: n
138     MAKE_OR_REUSE_FRAME(cache_frame_2179f2a37c0248d9475f34a5db027876, codeobj_2179f2a37c0248d9475f34a5db027876, module___main__, sizeof(void *)); 133     MAKE_OR_REUSE_FRAME(cache_frame_2179f2a37c0248d9475f34a5db027876, codeobj_2179f2a37c0248d9475f34a5db027876, module___main__, sizeof(void *));
139     frame_2179f2a37c0248d9475f34a5db027876 = cache_frame_2179f2a37c0248d9475f34a5db027876; 134     frame_2179f2a37c0248d9475f34a5db027876 = cache_frame_2179f2a37c0248d9475f34a5db027876;
140 135
141     // Push the new frame as the currently active one. 136     // Push the new frame as the currently active one.
142     pushFrameStack(frame_2179f2a37c0248d9475f34a5db027876); 137     pushFrameStack(frame_2179f2a37c0248d9475f34a5db027876);
161             exception_tb = NULL; 156             exception_tb = NULL;
162             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb); 157             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
163             CHAIN_EXCEPTION(exception_value); 158             CHAIN_EXCEPTION(exception_value);
164 159
165             exception_lineno = 24; 160             exception_lineno = 24;
n 166             type_description_1 = "o"; n 161             type_description_1 = "N";
167             goto frame_exception_exit_1; 162             goto frame_exception_exit_1;
168         } 163         }
169 164
n 170     } n
171     {
172         PyObject *tmp_assign_source_1;
173         PyObject *tmp_list_element_1;
174         PyObject *tmp_mvar_value_2;
175         PyObject *tmp_mvar_value_3;
176         PyObject *tmp_mvar_value_4;
177         PyObject *tmp_mvar_value_5;
178         PyObject *tmp_mvar_value_6;
179         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1);
180  
181         if (unlikely(tmp_mvar_value_2 == NULL)) {
182             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1);
183         }
184  
185         if (tmp_mvar_value_2 == NULL) {
186  
187             exception_type = PyExc_NameError;
188             Py_INCREF(exception_type);
189             exception_value = UNSTREAM_STRING(&constant_bin[ 0 ], 35, 0);
190             exception_tb = NULL;
191             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
192             CHAIN_EXCEPTION(exception_value);
193  
194             exception_lineno = 28;
195             type_description_1 = "o";
196             goto frame_exception_exit_1;
197         }
198  
199         tmp_list_element_1 = tmp_mvar_value_2;
200         tmp_assign_source_1 = PyList_New(5);
201         Py_INCREF(tmp_list_element_1);
202         PyList_SET_ITEM(tmp_assign_source_1, 0, tmp_list_element_1);
203         tmp_mvar_value_3 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1);
204  
205         if (unlikely(tmp_mvar_value_3 == NULL)) {
206             tmp_mvar_value_3 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1);
207         }
208  
209         if (tmp_mvar_value_3 == NULL) {
210             Py_DECREF(tmp_assign_source_1);
211             exception_type = PyExc_NameError;
212             Py_INCREF(exception_type);
213             exception_value = UNSTREAM_STRING(&constant_bin[ 0 ], 35, 0);
214             exception_tb = NULL;
215             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
216             CHAIN_EXCEPTION(exception_value);
217  
218             exception_lineno = 29;
219             type_description_1 = "o";
220             goto frame_exception_exit_1;
221         }
222  
223         tmp_list_element_1 = tmp_mvar_value_3;
224         Py_INCREF(tmp_list_element_1);
225         PyList_SET_ITEM(tmp_assign_source_1, 1, tmp_list_element_1);
226         tmp_mvar_value_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1);
227  
228         if (unlikely(tmp_mvar_value_4 == NULL)) {
229             tmp_mvar_value_4 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1);
230         }
231  
232         if (tmp_mvar_value_4 == NULL) {
233             Py_DECREF(tmp_assign_source_1);
234             exception_type = PyExc_NameError;
235             Py_INCREF(exception_type);
236             exception_value = UNSTREAM_STRING(&constant_bin[ 0 ], 35, 0);
237             exception_tb = NULL;
238             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
239             CHAIN_EXCEPTION(exception_value);
240  
241             exception_lineno = 30;
242             type_description_1 = "o";
243             goto frame_exception_exit_1;
244         }
245  
246         tmp_list_element_1 = tmp_mvar_value_4;
247         Py_INCREF(tmp_list_element_1);
248         PyList_SET_ITEM(tmp_assign_source_1, 2, tmp_list_element_1);
249         tmp_mvar_value_5 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1);
250  
251         if (unlikely(tmp_mvar_value_5 == NULL)) {
252             tmp_mvar_value_5 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1);
253         }
254  
255         if (tmp_mvar_value_5 == NULL) {
256             Py_DECREF(tmp_assign_source_1);
257             exception_type = PyExc_NameError;
258             Py_INCREF(exception_type);
259             exception_value = UNSTREAM_STRING(&constant_bin[ 0 ], 35, 0);
260             exception_tb = NULL;
261             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
262             CHAIN_EXCEPTION(exception_value);
263  
264             exception_lineno = 31;
265             type_description_1 = "o";
266             goto frame_exception_exit_1;
267         }
268  
269         tmp_list_element_1 = tmp_mvar_value_5;
270         Py_INCREF(tmp_list_element_1);
271         PyList_SET_ITEM(tmp_assign_source_1, 3, tmp_list_element_1);
272         tmp_mvar_value_6 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1);
273  
274         if (unlikely(tmp_mvar_value_6 == NULL)) {
275             tmp_mvar_value_6 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1);
276         }
277  
278         if (tmp_mvar_value_6 == NULL) {
279             Py_DECREF(tmp_assign_source_1);
280             exception_type = PyExc_NameError;
281             Py_INCREF(exception_type);
282             exception_value = UNSTREAM_STRING(&constant_bin[ 0 ], 35, 0);
283             exception_tb = NULL;
284             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
285             CHAIN_EXCEPTION(exception_value);
286  
287             exception_lineno = 32;
288             type_description_1 = "o";
289             goto frame_exception_exit_1;
290         }
291  
292         tmp_list_element_1 = tmp_mvar_value_6;
293         Py_INCREF(tmp_list_element_1);
294         PyList_SET_ITEM(tmp_assign_source_1, 4, tmp_list_element_1);
295         assert(var_l == NULL);
296         var_l = tmp_assign_source_1;
297     } 165     }
298 166
299 #if 0 167 #if 0
300     RESTORE_FRAME_EXCEPTION(frame_2179f2a37c0248d9475f34a5db027876); 168     RESTORE_FRAME_EXCEPTION(frame_2179f2a37c0248d9475f34a5db027876);
301 #endif 169 #endif
320 188
321     // Attachs locals to frame if any. 189     // Attachs locals to frame if any.
322     Nuitka_Frame_AttachLocals( 190     Nuitka_Frame_AttachLocals(
323         (struct Nuitka_FrameObject *)frame_2179f2a37c0248d9475f34a5db027876, 191         (struct Nuitka_FrameObject *)frame_2179f2a37c0248d9475f34a5db027876,
324         type_description_1, 192         type_description_1,
n 325         var_l n 193         NULL
326     ); 194     );
327 195
328 196
329     // Release cached frame. 197     // Release cached frame.
330     if (frame_2179f2a37c0248d9475f34a5db027876 == cache_frame_2179f2a37c0248d9475f34a5db027876) { 198     if (frame_2179f2a37c0248d9475f34a5db027876 == cache_frame_2179f2a37c0248d9475f34a5db027876) {
336 204
337     // Put the previous frame back on top. 205     // Put the previous frame back on top.
338     popFrameStack(); 206     popFrameStack();
339 207
340     // Return the error. 208     // Return the error.
n 341     goto try_except_handler_1; n 209     goto function_exception_exit;
342 210
343     frame_no_exception_1:; 211     frame_no_exception_1:;
n 344     CHECK_OBJECT(var_l); n 212     tmp_return_value = const_int_pos_1;
345     tmp_return_value = var_l;
346     Py_INCREF(tmp_return_value); 213     Py_INCREF(tmp_return_value);
n 347     goto try_return_handler_1; n
348     // tried codes exits in all cases
349     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
350     return NULL;
351     // Return handler code:
352     try_return_handler_1:;
353     CHECK_OBJECT((PyObject *)var_l);
354     Py_DECREF(var_l);
355     var_l = NULL;
356  
357     goto function_return_exit; 214     goto function_return_exit;
t 358     // Exception handler code: t
359     try_except_handler_1:;
360     exception_keeper_type_1 = exception_type;
361     exception_keeper_value_1 = exception_value;
362     exception_keeper_tb_1 = exception_tb;
363     exception_keeper_lineno_1 = exception_lineno;
364     exception_type = NULL;
365     exception_value = NULL;
366     exception_tb = NULL;
367     exception_lineno = 0;
368  
369     // Re-raise.
370     exception_type = exception_keeper_type_1;
371     exception_value = exception_keeper_value_1;
372     exception_tb = exception_keeper_tb_1;
373     exception_lineno = exception_keeper_lineno_1;
374  
375     goto function_exception_exit;
376     // End of try:
377 215
378     // Return statement must have exited already. 216     // Return statement must have exited already.
379     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 217     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
380     return NULL; 218     return NULL;
381 219