Construct TupleCreation

Performance Diagrams

Construct TupleCreation 0040000004000000800000080000001200000012000000160000001600000020000000200000002400000024000000280000002800000032000000320000003600000036000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3718504588.95192307692307257.0CPython 2.721449603242.31730769230768361.5707972633374Nuitka (master)21451631395.6826923076923361.5573200710952Nuitka (develop)21450917549.0480769230769361.56206499972484Nuitka (factory)Construct TupleCreationTicks Construct TupleCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)4070341388.95192307692307257.0CPython 3.523900323242.31730769230768359.0136087378452Nuitka (master)23899703395.6826923076923359.017372833462Nuitka (develop)23899695549.0480769230769359.01742140243766Nuitka (factory)Construct TupleCreationTicks

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