Construct TupleCreation

Performance Diagrams

Construct TupleCreation 004000000400000080000008000000120000001200000016000000160000002000000020000000240000002400000028000000280000003200000032000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3483957988.95192307692307257.0CPython 2.721200125242.31730769230768353.7439624099317Nuitka (master)21200125395.6826923076923353.7439624099317Nuitka (develop)21199566549.0480769230769353.74792736886536Nuitka (factory)Construct TupleCreationTicks Construct TupleCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)4075594588.95192307692307257.0CPython 3.523255927242.31730769230768363.10780044104376Nuitka (master)23270320395.6826923076923363.0205314124206Nuitka (develop)23270086549.0480769230769363.0219502238357Nuitka (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
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;
36 static PyObject *const_str_plain___package__; 36 static PyObject *const_str_plain___package__;
37 static PyObject *const_str_plain___spec__; 37 static PyObject *const_str_plain___spec__;
38 static PyObject *const_str_digest_5fd3dda9b3fbe7d4034ac7634bea73b7; 38 static PyObject *const_str_digest_5fd3dda9b3fbe7d4034ac7634bea73b7;
n n 39 extern PyObject *const_int_pos_1;
39 extern PyObject *const_dict_empty; 40 extern PyObject *const_dict_empty;
40 extern PyObject *const_str_plain___file__; 41 extern PyObject *const_str_plain___file__;
41 extern PyObject *const_int_0; 42 extern PyObject *const_int_0;
42 extern PyObject *const_str_plain_print; 43 extern PyObject *const_str_plain_print;
43 static PyObject *const_int_pos_50000; 44 static PyObject *const_int_pos_50000;
121 #ifndef __NUITKA_NO_ASSERT__ 122 #ifndef __NUITKA_NO_ASSERT__
122     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 123     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
123 #endif 124 #endif
124 125
125     // Local variable declarations. 126     // Local variable declarations.
n 126     PyObject *var_l = NULL; n
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     PyObject *exception_keeper_type_1; 131     PyObject *exception_keeper_type_1;
132     PyObject *exception_keeper_value_1; 132     PyObject *exception_keeper_value_1;
133     PyTracebackObject *exception_keeper_tb_1; 133     PyTracebackObject *exception_keeper_tb_1;
134     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 134     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 135     PyObject *tmp_assign_source_1; n
136     PyObject *tmp_return_value; 135     PyObject *tmp_return_value;
n 137     PyObject *tmp_tuple_element_1; n
138     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 136     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
139     static struct Nuitka_FrameObject *cache_frame_c4bebeb657e0284062df2ab501c5c76d = NULL; 137     static struct Nuitka_FrameObject *cache_frame_c4bebeb657e0284062df2ab501c5c76d = NULL;
140 138
141     struct Nuitka_FrameObject *frame_c4bebeb657e0284062df2ab501c5c76d; 139     struct Nuitka_FrameObject *frame_c4bebeb657e0284062df2ab501c5c76d;
142 140
143     char const *type_description; 141     char const *type_description;
144     tmp_return_value = NULL; 142     tmp_return_value = NULL;
145 143
146     // Actual function code. 144     // Actual function code.
147     // Tried code: 145     // Tried code:
n 148     MAKE_OR_REUSE_FRAME( cache_frame_c4bebeb657e0284062df2ab501c5c76d, codeobj_c4bebeb657e0284062df2ab501c5c76d, module___main__, sizeof(PyObject *) ); n 146     MAKE_OR_REUSE_FRAME( cache_frame_c4bebeb657e0284062df2ab501c5c76d, codeobj_c4bebeb657e0284062df2ab501c5c76d, module___main__, sizeof(void *) );
149     frame_c4bebeb657e0284062df2ab501c5c76d = cache_frame_c4bebeb657e0284062df2ab501c5c76d; 147     frame_c4bebeb657e0284062df2ab501c5c76d = cache_frame_c4bebeb657e0284062df2ab501c5c76d;
150 148
151     // Push the new frame as the currently active one. 149     // Push the new frame as the currently active one.
152     pushFrameStack( frame_c4bebeb657e0284062df2ab501c5c76d ); 150     pushFrameStack( frame_c4bebeb657e0284062df2ab501c5c76d );
153 151
171         exception_tb = NULL; 169         exception_tb = NULL;
172         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 170         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
173         CHAIN_EXCEPTION( exception_value ); 171         CHAIN_EXCEPTION( exception_value );
174 172
175         exception_lineno = 24; 173         exception_lineno = 24;
n 176         type_description = "o"; n 174         type_description = "N";
177         goto frame_exception_exit_1; 175         goto frame_exception_exit_1;
178     } 176     }
n 179   n
180     tmp_assign_source_1 = PyTuple_New( 5 );
181     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
182  
183     if (unlikely( tmp_tuple_element_1 == NULL ))
184     {
185         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
186     }
187  
188     if ( tmp_tuple_element_1 == NULL )
189     {
190         Py_DECREF( tmp_assign_source_1 );
191         exception_type = PyExc_NameError;
192         Py_INCREF( exception_type );
193         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
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 = "o";
200         goto frame_exception_exit_1;
201     }
202  
203     Py_INCREF( tmp_tuple_element_1 );
204     PyTuple_SET_ITEM( tmp_assign_source_1, 0, tmp_tuple_element_1 );
205     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
206  
207     if (unlikely( tmp_tuple_element_1 == NULL ))
208     {
209         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
210     }
211  
212     if ( tmp_tuple_element_1 == NULL )
213     {
214         Py_DECREF( tmp_assign_source_1 );
215         exception_type = PyExc_NameError;
216         Py_INCREF( exception_type );
217         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
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 = "o";
224         goto frame_exception_exit_1;
225     }
226  
227     Py_INCREF( tmp_tuple_element_1 );
228     PyTuple_SET_ITEM( tmp_assign_source_1, 1, tmp_tuple_element_1 );
229     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
230  
231     if (unlikely( tmp_tuple_element_1 == NULL ))
232     {
233         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
234     }
235  
236     if ( tmp_tuple_element_1 == NULL )
237     {
238         Py_DECREF( tmp_assign_source_1 );
239         exception_type = PyExc_NameError;
240         Py_INCREF( exception_type );
241         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
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 = "o";
248         goto frame_exception_exit_1;
249     }
250  
251     Py_INCREF( tmp_tuple_element_1 );
252     PyTuple_SET_ITEM( tmp_assign_source_1, 2, tmp_tuple_element_1 );
253     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
254  
255     if (unlikely( tmp_tuple_element_1 == NULL ))
256     {
257         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
258     }
259  
260     if ( tmp_tuple_element_1 == NULL )
261     {
262         Py_DECREF( tmp_assign_source_1 );
263         exception_type = PyExc_NameError;
264         Py_INCREF( exception_type );
265         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
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 = "o";
272         goto frame_exception_exit_1;
273     }
274  
275     Py_INCREF( tmp_tuple_element_1 );
276     PyTuple_SET_ITEM( tmp_assign_source_1, 3, tmp_tuple_element_1 );
277     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
278  
279     if (unlikely( tmp_tuple_element_1 == NULL ))
280     {
281         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
282     }
283  
284     if ( tmp_tuple_element_1 == NULL )
285     {
286         Py_DECREF( tmp_assign_source_1 );
287         exception_type = PyExc_NameError;
288         Py_INCREF( exception_type );
289         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
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 = "o";
296         goto frame_exception_exit_1;
297     }
298  
299     Py_INCREF( tmp_tuple_element_1 );
300     PyTuple_SET_ITEM( tmp_assign_source_1, 4, tmp_tuple_element_1 );
301     assert( var_l == NULL );
302     var_l = tmp_assign_source_1;
303 177
304 178
305 #if 0 179 #if 0
306     RESTORE_FRAME_EXCEPTION( frame_c4bebeb657e0284062df2ab501c5c76d ); 180     RESTORE_FRAME_EXCEPTION( frame_c4bebeb657e0284062df2ab501c5c76d );
307 #endif 181 #endif
324     else if ( exception_tb->tb_frame != &frame_c4bebeb657e0284062df2ab501c5c76d->m_frame ) 198     else if ( exception_tb->tb_frame != &frame_c4bebeb657e0284062df2ab501c5c76d->m_frame )
325     { 199     {
326         exception_tb = ADD_TRACEBACK( exception_tb, frame_c4bebeb657e0284062df2ab501c5c76d, exception_lineno ); 200         exception_tb = ADD_TRACEBACK( exception_tb, frame_c4bebeb657e0284062df2ab501c5c76d, exception_lineno );
327     } 201     }
328 202
n 329     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_c4bebeb657e0284062df2ab501c5c76d, type_description ,var_l ); n 203     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_c4bebeb657e0284062df2ab501c5c76d, type_description ,NULL );
330 204
331     // Release cached frame. 205     // Release cached frame.
332     if ( frame_c4bebeb657e0284062df2ab501c5c76d == cache_frame_c4bebeb657e0284062df2ab501c5c76d ) 206     if ( frame_c4bebeb657e0284062df2ab501c5c76d == cache_frame_c4bebeb657e0284062df2ab501c5c76d )
333     { 207     {
334         Py_DECREF( frame_c4bebeb657e0284062df2ab501c5c76d ); 208         Py_DECREF( frame_c4bebeb657e0284062df2ab501c5c76d );
344     // Return the error. 218     // Return the error.
345     goto try_except_handler_1; 219     goto try_except_handler_1;
346 220
347     frame_no_exception_1:; 221     frame_no_exception_1:;
348 222
n 349     tmp_return_value = var_l; n
350  
351     CHECK_OBJECT( tmp_return_value );
352     Py_INCREF( tmp_return_value );
353     goto try_return_handler_1; 223     goto try_end_1;
354     // tried codes exits in all cases
355     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
356     return NULL;
357     // Return handler code:
358     try_return_handler_1:;
359     CHECK_OBJECT( (PyObject *)var_l );
360     Py_DECREF( var_l );
361     var_l = NULL;
362  
363     goto function_return_exit;
364     // Exception handler code: 224     // Exception handler code:
365     try_except_handler_1:; 225     try_except_handler_1:;
366     exception_keeper_type_1 = exception_type; 226     exception_keeper_type_1 = exception_type;
367     exception_keeper_value_1 = exception_value; 227     exception_keeper_value_1 = exception_value;
368     exception_keeper_tb_1 = exception_tb; 228     exception_keeper_tb_1 = exception_tb;
378     exception_tb = exception_keeper_tb_1; 238     exception_tb = exception_keeper_tb_1;
379     exception_lineno = exception_keeper_lineno_1; 239     exception_lineno = exception_keeper_lineno_1;
380 240
381     goto function_exception_exit; 241     goto function_exception_exit;
382     // End of try: 242     // End of try:
t t 243     try_end_1:;
244     tmp_return_value = const_int_pos_1;
245     Py_INCREF( tmp_return_value );
246     goto function_return_exit;
383 247
384     // Return statement must have exited already. 248     // Return statement must have exited already.
385     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 249     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
386     return NULL; 250     return NULL;
387 251