Construct TupleCreation

Performance Diagrams

Construct TupleCreation 0040000004000000800000080000001200000012000000160000001600000020000000200000002400000024000000280000002800000032000000320000003600000036000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3747807288.95192307692307257.0CPython 2.721599688242.31730769230768361.6956996408665Nuitka (master)21599159395.6826923076923361.69918765483Nuitka (develop)21599933549.0480769230769361.69408420906865Nuitka (factory)Construct TupleCreationTicks Construct TupleCreation 0040000004000000800000080000001200000012000000160000001600000020000000200000002400000024000000280000002800000032000000320000003600000036000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)3950034488.95192307692307257.00000000000006CPython 3.523599944242.31730769230768356.47339854909774Nuitka (master)23599617395.6826923076923356.47544427130134Nuitka (develop)23599443549.0480769230769356.47653282073077Nuitka (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
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_str_digest_b7e4058fc62da2bcbbe30e901de619a2; 35 static PyObject *const_str_digest_b7e4058fc62da2bcbbe30e901de619a2;
36 static PyObject *const_tuple_str_plain_l_tuple; 36 static PyObject *const_tuple_str_plain_l_tuple;
n n 37 extern PyObject *const_int_pos_1;
37 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
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;
41 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
119 #ifndef __NUITKA_NO_ASSERT__ 120 #ifndef __NUITKA_NO_ASSERT__
120     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 121     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
121 #endif 122 #endif
122 123
123     // Local variable declarations. 124     // Local variable declarations.
n 124     PyObject *var_l = NULL; n
125     struct Nuitka_FrameObject *frame_2bc4540f5dcb52b1347e7e042d3d8c02; 125     struct Nuitka_FrameObject *frame_2bc4540f5dcb52b1347e7e042d3d8c02;
126     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 126     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
127     PyObject *exception_type = NULL; 127     PyObject *exception_type = NULL;
128     PyObject *exception_value = NULL; 128     PyObject *exception_value = NULL;
129     PyTracebackObject *exception_tb = NULL; 129     PyTracebackObject *exception_tb = NULL;
130     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 130     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
131     static struct Nuitka_FrameObject *cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02 = NULL; 131     static struct Nuitka_FrameObject *cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02 = NULL;
132     PyObject *tmp_return_value = NULL; 132     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 133
138     // Actual function body. 134     // Actual function body.
n 139     // Tried code: n
140     MAKE_OR_REUSE_FRAME( cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02, codeobj_2bc4540f5dcb52b1347e7e042d3d8c02, module___main__, sizeof(void *) ); 135     MAKE_OR_REUSE_FRAME( cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02, codeobj_2bc4540f5dcb52b1347e7e042d3d8c02, module___main__, sizeof(void *) );
141     frame_2bc4540f5dcb52b1347e7e042d3d8c02 = cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02; 136     frame_2bc4540f5dcb52b1347e7e042d3d8c02 = cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02;
142 137
143     // Push the new frame as the currently active one. 138     // Push the new frame as the currently active one.
144     pushFrameStack( frame_2bc4540f5dcb52b1347e7e042d3d8c02 ); 139     pushFrameStack( frame_2bc4540f5dcb52b1347e7e042d3d8c02 );
165             exception_tb = NULL; 160             exception_tb = NULL;
166             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 161             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
167             CHAIN_EXCEPTION( exception_value ); 162             CHAIN_EXCEPTION( exception_value );
168 163
169             exception_lineno = 24; 164             exception_lineno = 24;
n 170             type_description_1 = "o"; n 165             type_description_1 = "N";
171             goto frame_exception_exit_1; 166             goto frame_exception_exit_1;
172         } 167         }
173 168
n 174     } n
175     {
176         PyObject *tmp_assign_source_1;
177         PyObject *tmp_tuple_element_1;
178         PyObject *tmp_mvar_value_2;
179         PyObject *tmp_mvar_value_3;
180         PyObject *tmp_mvar_value_4;
181         PyObject *tmp_mvar_value_5;
182         PyObject *tmp_mvar_value_6;
183         tmp_mvar_value_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
184  
185         if (unlikely( tmp_mvar_value_2 == NULL ))
186         {
187             tmp_mvar_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
188         }
189  
190         if ( tmp_mvar_value_2 == NULL )
191         {
192  
193             exception_type = PyExc_NameError;
194             Py_INCREF( exception_type );
195             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
196             exception_tb = NULL;
197             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
198             CHAIN_EXCEPTION( exception_value );
199  
200             exception_lineno = 28;
201             type_description_1 = "o";
202             goto frame_exception_exit_1;
203         }
204  
205         tmp_tuple_element_1 = tmp_mvar_value_2;
206         tmp_assign_source_1 = PyTuple_New( 5 );
207         Py_INCREF( tmp_tuple_element_1 );
208         PyTuple_SET_ITEM( tmp_assign_source_1, 0, tmp_tuple_element_1 );
209         tmp_mvar_value_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
210  
211         if (unlikely( tmp_mvar_value_3 == NULL ))
212         {
213             tmp_mvar_value_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
214         }
215  
216         if ( tmp_mvar_value_3 == NULL )
217         {
218             Py_DECREF( tmp_assign_source_1 );
219             exception_type = PyExc_NameError;
220             Py_INCREF( exception_type );
221             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
222             exception_tb = NULL;
223             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
224             CHAIN_EXCEPTION( exception_value );
225  
226             exception_lineno = 29;
227             type_description_1 = "o";
228             goto frame_exception_exit_1;
229         }
230  
231         tmp_tuple_element_1 = tmp_mvar_value_3;
232         Py_INCREF( tmp_tuple_element_1 );
233         PyTuple_SET_ITEM( tmp_assign_source_1, 1, tmp_tuple_element_1 );
234         tmp_mvar_value_4 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
235  
236         if (unlikely( tmp_mvar_value_4 == NULL ))
237         {
238             tmp_mvar_value_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
239         }
240  
241         if ( tmp_mvar_value_4 == NULL )
242         {
243             Py_DECREF( tmp_assign_source_1 );
244             exception_type = PyExc_NameError;
245             Py_INCREF( exception_type );
246             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
247             exception_tb = NULL;
248             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
249             CHAIN_EXCEPTION( exception_value );
250  
251             exception_lineno = 30;
252             type_description_1 = "o";
253             goto frame_exception_exit_1;
254         }
255  
256         tmp_tuple_element_1 = tmp_mvar_value_4;
257         Py_INCREF( tmp_tuple_element_1 );
258         PyTuple_SET_ITEM( tmp_assign_source_1, 2, tmp_tuple_element_1 );
259         tmp_mvar_value_5 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
260  
261         if (unlikely( tmp_mvar_value_5 == NULL ))
262         {
263             tmp_mvar_value_5 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
264         }
265  
266         if ( tmp_mvar_value_5 == NULL )
267         {
268             Py_DECREF( tmp_assign_source_1 );
269             exception_type = PyExc_NameError;
270             Py_INCREF( exception_type );
271             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
272             exception_tb = NULL;
273             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
274             CHAIN_EXCEPTION( exception_value );
275  
276             exception_lineno = 31;
277             type_description_1 = "o";
278             goto frame_exception_exit_1;
279         }
280  
281         tmp_tuple_element_1 = tmp_mvar_value_5;
282         Py_INCREF( tmp_tuple_element_1 );
283         PyTuple_SET_ITEM( tmp_assign_source_1, 3, tmp_tuple_element_1 );
284         tmp_mvar_value_6 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
285  
286         if (unlikely( tmp_mvar_value_6 == NULL ))
287         {
288             tmp_mvar_value_6 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
289         }
290  
291         if ( tmp_mvar_value_6 == NULL )
292         {
293             Py_DECREF( tmp_assign_source_1 );
294             exception_type = PyExc_NameError;
295             Py_INCREF( exception_type );
296             exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
297             exception_tb = NULL;
298             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
299             CHAIN_EXCEPTION( exception_value );
300  
301             exception_lineno = 32;
302             type_description_1 = "o";
303             goto frame_exception_exit_1;
304         }
305  
306         tmp_tuple_element_1 = tmp_mvar_value_6;
307         Py_INCREF( tmp_tuple_element_1 );
308         PyTuple_SET_ITEM( tmp_assign_source_1, 4, tmp_tuple_element_1 );
309         assert( var_l == NULL );
310         var_l = tmp_assign_source_1;
311     } 169     }
312 170
313 #if 0 171 #if 0
314     RESTORE_FRAME_EXCEPTION( frame_2bc4540f5dcb52b1347e7e042d3d8c02 ); 172     RESTORE_FRAME_EXCEPTION( frame_2bc4540f5dcb52b1347e7e042d3d8c02 );
315 #endif 173 #endif
336 194
337     // Attachs locals to frame if any. 195     // Attachs locals to frame if any.
338     Nuitka_Frame_AttachLocals( 196     Nuitka_Frame_AttachLocals(
339         (struct Nuitka_FrameObject *)frame_2bc4540f5dcb52b1347e7e042d3d8c02, 197         (struct Nuitka_FrameObject *)frame_2bc4540f5dcb52b1347e7e042d3d8c02,
340         type_description_1, 198         type_description_1,
n 341         var_l n 199         NULL
342     ); 200     );
343 201
344 202
345     // Release cached frame. 203     // Release cached frame.
346     if ( frame_2bc4540f5dcb52b1347e7e042d3d8c02 == cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02 ) 204     if ( frame_2bc4540f5dcb52b1347e7e042d3d8c02 == cache_frame_2bc4540f5dcb52b1347e7e042d3d8c02 )
353 211
354     // Put the previous frame back on top. 212     // Put the previous frame back on top.
355     popFrameStack(); 213     popFrameStack();
356 214
357     // Return the error. 215     // Return the error.
n 358     goto try_except_handler_1; n 216     goto function_exception_exit;
359 217
360     frame_no_exception_1:; 218     frame_no_exception_1:;
n 361     CHECK_OBJECT( var_l ); n 219     tmp_return_value = const_int_pos_1;
362     tmp_return_value = var_l;
363     Py_INCREF( tmp_return_value ); 220     Py_INCREF( tmp_return_value );
n 364     goto try_return_handler_1; n
365     // tried codes exits in all cases
366     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
367     return NULL;
368     // Return handler code:
369     try_return_handler_1:;
370     CHECK_OBJECT( (PyObject *)var_l );
371     Py_DECREF( var_l );
372     var_l = NULL;
373  
374     goto function_return_exit; 221     goto function_return_exit;
t 375     // Exception handler code: t
376     try_except_handler_1:;
377     exception_keeper_type_1 = exception_type;
378     exception_keeper_value_1 = exception_value;
379     exception_keeper_tb_1 = exception_tb;
380     exception_keeper_lineno_1 = exception_lineno;
381     exception_type = NULL;
382     exception_value = NULL;
383     exception_tb = NULL;
384     exception_lineno = 0;
385  
386     // Re-raise.
387     exception_type = exception_keeper_type_1;
388     exception_value = exception_keeper_value_1;
389     exception_tb = exception_keeper_tb_1;
390     exception_lineno = exception_keeper_lineno_1;
391  
392     goto function_exception_exit;
393     // End of try:
394 222
395     // Return statement must have exited already. 223     // Return statement must have exited already.
396     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 224     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
397     return NULL; 225     return NULL;
398 226