Construct TupleCreation

Performance Diagrams

Construct TupleCreation 004000000400000080000008000000120000001200000016000000160000002000000020000000240000002400000028000000280000003200000032000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)3483948673.61538461538461257.0CPython 2.721399322196.30769230769232352.3306629194773Nuitka (historic)21199609319.0000000000001353.74722098258104Nuitka (master)21150563441.69230769230774354.09510272669877Nuitka (develop)21199446564.3846153846155353.7483771364833Nuitka (factory)Construct TupleCreationTicks Construct TupleCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)4075639573.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)23250901319.0000000000001363.1398311281532Nuitka (master)23251770441.69230769230774363.1345621815442Nuitka (develop)23252448564.3846153846155363.13045131180786Nuitka (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

for x in xrange(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

for x in xrange(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 for x in xrange(50000): 41 for x in xrange(50000):

Context Diff of Generated Code


Construct
Baseline
113 #ifndef __NUITKA_NO_ASSERT__ 113 #ifndef __NUITKA_NO_ASSERT__
114     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 114     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
115 #endif 115 #endif
116 116
117     // Local variable declarations. 117     // Local variable declarations.
n 118     PyObject *var_l = NULL; n
119     PyObject *exception_type = NULL, *exception_value = NULL; 118     PyObject *exception_type = NULL, *exception_value = NULL;
120     PyTracebackObject *exception_tb = NULL; 119     PyTracebackObject *exception_tb = NULL;
121     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 120     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
122     PyObject *exception_keeper_type_1; 121     PyObject *exception_keeper_type_1;
123     PyObject *exception_keeper_value_1; 122     PyObject *exception_keeper_value_1;
124     PyTracebackObject *exception_keeper_tb_1; 123     PyTracebackObject *exception_keeper_tb_1;
125     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 124     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 126     PyObject *tmp_assign_source_1; n
127     PyObject *tmp_return_value; 125     PyObject *tmp_return_value;
n 128     PyObject *tmp_tuple_element_1; n
129     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 126     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
130     static struct Nuitka_FrameObject *cache_frame_475765a89595644f4c5f9ef80565feed = NULL; 127     static struct Nuitka_FrameObject *cache_frame_475765a89595644f4c5f9ef80565feed = NULL;
131 128
132     struct Nuitka_FrameObject *frame_475765a89595644f4c5f9ef80565feed; 129     struct Nuitka_FrameObject *frame_475765a89595644f4c5f9ef80565feed;
133 130
134     char const *type_description; 131     char const *type_description;
135     tmp_return_value = NULL; 132     tmp_return_value = NULL;
136 133
137     // Actual function code. 134     // Actual function code.
138     // Tried code: 135     // Tried code:
n 139     MAKE_OR_REUSE_FRAME( cache_frame_475765a89595644f4c5f9ef80565feed, codeobj_475765a89595644f4c5f9ef80565feed, module___main__, sizeof(PyObject *) ); n 136     MAKE_OR_REUSE_FRAME( cache_frame_475765a89595644f4c5f9ef80565feed, codeobj_475765a89595644f4c5f9ef80565feed, module___main__, sizeof(void *) );
140     frame_475765a89595644f4c5f9ef80565feed = cache_frame_475765a89595644f4c5f9ef80565feed; 137     frame_475765a89595644f4c5f9ef80565feed = cache_frame_475765a89595644f4c5f9ef80565feed;
141 138
142     // Push the new frame as the currently active one. 139     // Push the new frame as the currently active one.
143     pushFrameStack( frame_475765a89595644f4c5f9ef80565feed ); 140     pushFrameStack( frame_475765a89595644f4c5f9ef80565feed );
144 141
162         exception_tb = NULL; 159         exception_tb = NULL;
163         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 160         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
164         CHAIN_EXCEPTION( exception_value ); 161         CHAIN_EXCEPTION( exception_value );
165 162
166         exception_lineno = 24; 163         exception_lineno = 24;
n 167         type_description = "o"; n 164         type_description = "N";
168         goto frame_exception_exit_1; 165         goto frame_exception_exit_1;
169     } 166     }
n 170   n
171     tmp_assign_source_1 = PyTuple_New( 5 );
172     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
173  
174     if (unlikely( tmp_tuple_element_1 == NULL ))
175     {
176         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
177     }
178  
179     if ( tmp_tuple_element_1 == NULL )
180     {
181         Py_DECREF( tmp_assign_source_1 );
182         exception_type = PyExc_NameError;
183         Py_INCREF( exception_type );
184         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
185         exception_tb = NULL;
186         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
187         CHAIN_EXCEPTION( exception_value );
188  
189         exception_lineno = 28;
190         type_description = "o";
191         goto frame_exception_exit_1;
192     }
193  
194     Py_INCREF( tmp_tuple_element_1 );
195     PyTuple_SET_ITEM( tmp_assign_source_1, 0, tmp_tuple_element_1 );
196     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
197  
198     if (unlikely( tmp_tuple_element_1 == NULL ))
199     {
200         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
201     }
202  
203     if ( tmp_tuple_element_1 == NULL )
204     {
205         Py_DECREF( tmp_assign_source_1 );
206         exception_type = PyExc_NameError;
207         Py_INCREF( exception_type );
208         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
209         exception_tb = NULL;
210         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
211         CHAIN_EXCEPTION( exception_value );
212  
213         exception_lineno = 29;
214         type_description = "o";
215         goto frame_exception_exit_1;
216     }
217  
218     Py_INCREF( tmp_tuple_element_1 );
219     PyTuple_SET_ITEM( tmp_assign_source_1, 1, tmp_tuple_element_1 );
220     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
221  
222     if (unlikely( tmp_tuple_element_1 == NULL ))
223     {
224         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
225     }
226  
227     if ( tmp_tuple_element_1 == NULL )
228     {
229         Py_DECREF( tmp_assign_source_1 );
230         exception_type = PyExc_NameError;
231         Py_INCREF( exception_type );
232         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
233         exception_tb = NULL;
234         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
235         CHAIN_EXCEPTION( exception_value );
236  
237         exception_lineno = 30;
238         type_description = "o";
239         goto frame_exception_exit_1;
240     }
241  
242     Py_INCREF( tmp_tuple_element_1 );
243     PyTuple_SET_ITEM( tmp_assign_source_1, 2, tmp_tuple_element_1 );
244     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
245  
246     if (unlikely( tmp_tuple_element_1 == NULL ))
247     {
248         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
249     }
250  
251     if ( tmp_tuple_element_1 == NULL )
252     {
253         Py_DECREF( tmp_assign_source_1 );
254         exception_type = PyExc_NameError;
255         Py_INCREF( exception_type );
256         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
257         exception_tb = NULL;
258         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
259         CHAIN_EXCEPTION( exception_value );
260  
261         exception_lineno = 31;
262         type_description = "o";
263         goto frame_exception_exit_1;
264     }
265  
266     Py_INCREF( tmp_tuple_element_1 );
267     PyTuple_SET_ITEM( tmp_assign_source_1, 3, tmp_tuple_element_1 );
268     tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
269  
270     if (unlikely( tmp_tuple_element_1 == NULL ))
271     {
272         tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
273     }
274  
275     if ( tmp_tuple_element_1 == NULL )
276     {
277         Py_DECREF( tmp_assign_source_1 );
278         exception_type = PyExc_NameError;
279         Py_INCREF( exception_type );
280         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
281         exception_tb = NULL;
282         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
283         CHAIN_EXCEPTION( exception_value );
284  
285         exception_lineno = 32;
286         type_description = "o";
287         goto frame_exception_exit_1;
288     }
289  
290     Py_INCREF( tmp_tuple_element_1 );
291     PyTuple_SET_ITEM( tmp_assign_source_1, 4, tmp_tuple_element_1 );
292     assert( var_l == NULL );
293     var_l = tmp_assign_source_1;
294 167
295 168
296 #if 0 169 #if 0
297     RESTORE_FRAME_EXCEPTION( frame_475765a89595644f4c5f9ef80565feed ); 170     RESTORE_FRAME_EXCEPTION( frame_475765a89595644f4c5f9ef80565feed );
298 #endif 171 #endif
315     else if ( exception_tb->tb_frame != &frame_475765a89595644f4c5f9ef80565feed->m_frame ) 188     else if ( exception_tb->tb_frame != &frame_475765a89595644f4c5f9ef80565feed->m_frame )
316     { 189     {
317         exception_tb = ADD_TRACEBACK( exception_tb, frame_475765a89595644f4c5f9ef80565feed, exception_lineno ); 190         exception_tb = ADD_TRACEBACK( exception_tb, frame_475765a89595644f4c5f9ef80565feed, exception_lineno );
318     } 191     }
319 192
n 320     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_475765a89595644f4c5f9ef80565feed, type_description ,var_l ); n 193     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_475765a89595644f4c5f9ef80565feed, type_description ,NULL );
321 194
322     // Release cached frame. 195     // Release cached frame.
323     if ( frame_475765a89595644f4c5f9ef80565feed == cache_frame_475765a89595644f4c5f9ef80565feed ) 196     if ( frame_475765a89595644f4c5f9ef80565feed == cache_frame_475765a89595644f4c5f9ef80565feed )
324     { 197     {
325         Py_DECREF( frame_475765a89595644f4c5f9ef80565feed ); 198         Py_DECREF( frame_475765a89595644f4c5f9ef80565feed );
335     // Return the error. 208     // Return the error.
336     goto try_except_handler_1; 209     goto try_except_handler_1;
337 210
338     frame_no_exception_1:; 211     frame_no_exception_1:;
339 212
n 340     tmp_return_value = var_l; n
341  
342     CHECK_OBJECT( tmp_return_value );
343     Py_INCREF( tmp_return_value );
344     goto try_return_handler_1; 213     goto try_end_1;
345     // tried codes exits in all cases
346     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
347     return NULL;
348     // Return handler code:
349     try_return_handler_1:;
350     CHECK_OBJECT( (PyObject *)var_l );
351     Py_DECREF( var_l );
352     var_l = NULL;
353  
354     goto function_return_exit;
355     // Exception handler code: 214     // Exception handler code:
356     try_except_handler_1:; 215     try_except_handler_1:;
357     exception_keeper_type_1 = exception_type; 216     exception_keeper_type_1 = exception_type;
358     exception_keeper_value_1 = exception_value; 217     exception_keeper_value_1 = exception_value;
359     exception_keeper_tb_1 = exception_tb; 218     exception_keeper_tb_1 = exception_tb;
369     exception_tb = exception_keeper_tb_1; 228     exception_tb = exception_keeper_tb_1;
370     exception_lineno = exception_keeper_lineno_1; 229     exception_lineno = exception_keeper_lineno_1;
371 230
372     goto function_exception_exit; 231     goto function_exception_exit;
373     // End of try: 232     // End of try:
t t 233     try_end_1:;
234     tmp_return_value = const_int_pos_1;
235     Py_INCREF( tmp_return_value );
236     goto function_return_exit;
374 237
375     // Return statement must have exited already. 238     // Return statement must have exited already.
376     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 239     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
377     return NULL; 240     return NULL;
378 241