Construct LoopSmallRange

Performance Diagrams

Construct LoopSmallRange 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)11087555788.11538461538461257.0CPython 2.752255226240.03846153846155387.65084887326566Nuitka (master)52255262391.96153846153845387.6507686377829Nuitka (develop)52255460543.8846153846154387.6503273426275Nuitka (factory)Construct LoopSmallRangeTicks Construct LoopSmallRange 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)14521882688.11538461538461257.00000000000006CPython 3.587838909240.03846153846155354.642025136974Nuitka (master)87858942391.96153846153845354.6079354625402Nuitka (develop)87859006543.8846153846154354.60782655527896Nuitka (factory)Construct LoopSmallRangeTicks

Source Code with Construct

module_value1 = 5
module_value2 = 3

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    # Make sure we have a local variable x anyway
    x = 2

    local_value = module_value1

# construct_begin
    for x in range(local_value, local_value+3):
        pass
# construct_end

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 5
module_value2 = 3

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    # Make sure we have a local variable x anyway
    x = 2

    local_value = module_value1

# construct_begin




import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
29     x = 2 29     x = 2
30 30
31     local_value = module_value1 31     local_value = module_value1
32 32
33 # construct_begin 33 # construct_begin
t 34     for x in range(local_value, local_value+3): t 34  
35         pass 35  
36 # construct_end 36  
37 37
38 import itertools 38 import itertools
39 for x in itertools.repeat(None, 50000): 39 for x in itertools.repeat(None, 50000):
40     calledRepeatedly() 40     calledRepeatedly()
41 41

Context Diff of Generated Code


Construct
Baseline
50 extern PyObject *const_tuple_empty; 50 extern PyObject *const_tuple_empty;
51 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 51 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
52 static PyObject *const_int_pos_5; 52 static PyObject *const_int_pos_5;
53 static PyObject *const_str_plain_repeat; 53 static PyObject *const_str_plain_repeat;
54 static PyObject *const_str_digest_77cb20f68e584c870729eb8054a459a1; 54 static PyObject *const_str_digest_77cb20f68e584c870729eb8054a459a1;
n 55 static PyObject *const_int_pos_2; n
56 static PyObject *const_tuple_none_int_pos_50000_tuple; 55 static PyObject *const_tuple_none_int_pos_50000_tuple;
57 static PyObject *const_tuple_str_plain_x_str_plain_local_value_tuple; 56 static PyObject *const_tuple_str_plain_x_str_plain_local_value_tuple;
58 extern PyObject *const_str_plain___loader__; 57 extern PyObject *const_str_plain___loader__;
59 extern PyObject *const_str_plain___main__; 58 extern PyObject *const_str_plain___main__;
60 extern PyObject *const_str_plain___doc__; 59 extern PyObject *const_str_plain___doc__;
80     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 84 ], 8, 0 ); 79     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 84 ], 8, 0 );
81     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 92 ], 1, 1 ); 80     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 92 ], 1, 1 );
82     const_int_pos_5 = PyLong_FromUnsignedLong( 5ul ); 81     const_int_pos_5 = PyLong_FromUnsignedLong( 5ul );
83     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 93 ], 6, 1 ); 82     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 93 ], 6, 1 );
84     const_str_digest_77cb20f68e584c870729eb8054a459a1 = UNSTREAM_STRING( &constant_bin[ 99 ], 72, 0 ); 83     const_str_digest_77cb20f68e584c870729eb8054a459a1 = UNSTREAM_STRING( &constant_bin[ 99 ], 72, 0 );
n 85     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul ); n
86     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 84     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
87     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 85     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
88     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 86     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
89     const_tuple_str_plain_x_str_plain_local_value_tuple = PyTuple_New( 2 ); 87     const_tuple_str_plain_x_str_plain_local_value_tuple = PyTuple_New( 2 );
90     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 0, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 88     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 0, const_str_plain_x ); Py_INCREF( const_str_plain_x );
128 #ifndef __NUITKA_NO_ASSERT__ 126 #ifndef __NUITKA_NO_ASSERT__
129     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 127     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
130 #endif 128 #endif
131 129
132     // Local variable declarations. 130     // Local variable declarations.
n 133     PyObject *var_x = NULL; n
134     PyObject *var_local_value = NULL; 131     PyObject *var_local_value = NULL;
n 135     PyObject *tmp_for_loop_1__for_iterator = NULL; n
136     PyObject *tmp_for_loop_1__iter_value = NULL;
137     PyObject *exception_type = NULL; 132     PyObject *exception_type = NULL;
138     PyObject *exception_value = NULL; 133     PyObject *exception_value = NULL;
139     PyTracebackObject *exception_tb = NULL; 134     PyTracebackObject *exception_tb = NULL;
140     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 135     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
141     PyObject *exception_keeper_type_1; 136     PyObject *exception_keeper_type_1;
142     PyObject *exception_keeper_value_1; 137     PyObject *exception_keeper_value_1;
143     PyTracebackObject *exception_keeper_tb_1; 138     PyTracebackObject *exception_keeper_tb_1;
144     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 139     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 145     PyObject *exception_keeper_type_2; n
146     PyObject *exception_keeper_value_2;
147     PyTracebackObject *exception_keeper_tb_2;
148     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
149     PyObject *tmp_assign_source_1; 140     PyObject *tmp_assign_source_1;
n 150     PyObject *tmp_assign_source_2; n
151     PyObject *tmp_assign_source_3;
152     PyObject *tmp_assign_source_4;
153     PyObject *tmp_assign_source_5;
154     PyObject *tmp_iter_arg_1;
155     PyObject *tmp_left_name_1;
156     PyObject *tmp_next_source_1;
157     PyObject *tmp_return_value; 141     PyObject *tmp_return_value;
n 158     PyObject *tmp_right_name_1; n
159     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 142     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
n 160     PyObject *tmp_xrange_high_1; n
161     PyObject *tmp_xrange_low_1;
162     static struct Nuitka_FrameObject *cache_frame_0f1310ef1b512d4da200175ea0fec3df = NULL; 143     static struct Nuitka_FrameObject *cache_frame_0f1310ef1b512d4da200175ea0fec3df = NULL;
163 144
164     struct Nuitka_FrameObject *frame_0f1310ef1b512d4da200175ea0fec3df; 145     struct Nuitka_FrameObject *frame_0f1310ef1b512d4da200175ea0fec3df;
165 146
166     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 147     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
194         exception_tb = NULL; 175         exception_tb = NULL;
195         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 176         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
196         CHAIN_EXCEPTION( exception_value ); 177         CHAIN_EXCEPTION( exception_value );
197 178
198         exception_lineno = 26; 179         exception_lineno = 26;
n 199         type_description_1 = "oo"; n 180         type_description_1 = "No";
200         goto frame_exception_exit_1; 181         goto frame_exception_exit_1;
201     } 182     }
202 183
n 203     tmp_assign_source_1 = const_int_pos_2; n
204     assert( var_x == NULL );
205     Py_INCREF( tmp_assign_source_1 );
206     var_x = tmp_assign_source_1;
207  
208     tmp_assign_source_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 ); 184     tmp_assign_source_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
209 185
n 210     if (unlikely( tmp_assign_source_2 == NULL )) n 186     if (unlikely( tmp_assign_source_1 == NULL ))
211     { 187     {
n 212         tmp_assign_source_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 ); n 188         tmp_assign_source_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
213     } 189     }
214 190
n 215     if ( tmp_assign_source_2 == NULL ) n 191     if ( tmp_assign_source_1 == NULL )
216     { 192     {
217 193
218         exception_type = PyExc_NameError; 194         exception_type = PyExc_NameError;
219         Py_INCREF( exception_type ); 195         Py_INCREF( exception_type );
220         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" ); 196         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
221         exception_tb = NULL; 197         exception_tb = NULL;
222         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 198         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
223         CHAIN_EXCEPTION( exception_value ); 199         CHAIN_EXCEPTION( exception_value );
224 200
225         exception_lineno = 31; 201         exception_lineno = 31;
n 226         type_description_1 = "oo"; n 202         type_description_1 = "No";
227         goto frame_exception_exit_1; 203         goto frame_exception_exit_1;
228     } 204     }
229 205
230     assert( var_local_value == NULL ); 206     assert( var_local_value == NULL );
n 231     Py_INCREF( tmp_assign_source_2 ); n 207     Py_INCREF( tmp_assign_source_1 );
232     var_local_value = tmp_assign_source_2; 208     var_local_value = tmp_assign_source_1;
233 209
n 234     tmp_xrange_low_1 = var_local_value; n
235 210
n 236     CHECK_OBJECT( tmp_xrange_low_1 ); n 211 #if 0
237     tmp_left_name_1 = var_local_value; 212     RESTORE_FRAME_EXCEPTION( frame_0f1310ef1b512d4da200175ea0fec3df );
213 #endif
238 214
n 239     CHECK_OBJECT( tmp_left_name_1 ); n 215     // Put the previous frame back on top.
240     tmp_right_name_1 = const_int_pos_3; 216     popFrameStack();
241     tmp_xrange_high_1 = BINARY_OPERATION_ADD( tmp_left_name_1, tmp_right_name_1 ); 217  
242     if ( tmp_xrange_high_1 == NULL ) 218     goto frame_no_exception_1;
219  
220     frame_exception_exit_1:;
221  
222 #if 0
223     RESTORE_FRAME_EXCEPTION( frame_0f1310ef1b512d4da200175ea0fec3df );
224 #endif
225  
226     if ( exception_tb == NULL )
227     {
228         exception_tb = MAKE_TRACEBACK( frame_0f1310ef1b512d4da200175ea0fec3df, exception_lineno );
243     { 229     }
244         assert( ERROR_OCCURRED() ); 230     else if ( exception_tb->tb_frame != &frame_0f1310ef1b512d4da200175ea0fec3df->m_frame )
231     {
232         exception_tb = ADD_TRACEBACK( exception_tb, frame_0f1310ef1b512d4da200175ea0fec3df, exception_lineno );
233     }
245 234
n 246         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 235     // Attachs locals to frame if any.
247   236     Nuitka_Frame_AttachLocals(
248   237         (struct Nuitka_FrameObject *)frame_0f1310ef1b512d4da200175ea0fec3df,
249         exception_lineno = 34;
250         type_description_1 = "oo"; 238         type_description_1,
251         goto frame_exception_exit_1; 239         NULL,
240         var_local_value
241     );
242  
243  
244     // Release cached frame.
245     if ( frame_0f1310ef1b512d4da200175ea0fec3df == cache_frame_0f1310ef1b512d4da200175ea0fec3df )
252     } 246     {
253     tmp_iter_arg_1 = BUILTIN_XRANGE2( tmp_xrange_low_1, tmp_xrange_high_1 ); 247         Py_DECREF( frame_0f1310ef1b512d4da200175ea0fec3df );
254     Py_DECREF( tmp_xrange_high_1 );
255     if ( tmp_iter_arg_1 == NULL )
256     { 248     }
257         assert( ERROR_OCCURRED() ); 249     cache_frame_0f1310ef1b512d4da200175ea0fec3df = NULL;
258 250
n 259         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 251     assertFrameObject( frame_0f1310ef1b512d4da200175ea0fec3df );
260 252
n n 253     // Put the previous frame back on top.
254     popFrameStack();
261 255
n 262         exception_lineno = 34; n 256     // Return the error.
263         type_description_1 = "oo";
264         goto frame_exception_exit_1;
265     }
266     tmp_assign_source_3 = MAKE_ITERATOR( tmp_iter_arg_1 );
267     Py_DECREF( tmp_iter_arg_1 );
268     if ( tmp_assign_source_3 == NULL )
269     {
270         assert( ERROR_OCCURRED() );
271  
272         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
273  
274  
275         exception_lineno = 34;
276         type_description_1 = "oo";
277         goto frame_exception_exit_1;
278     }
279     assert( tmp_for_loop_1__for_iterator == NULL );
280     tmp_for_loop_1__for_iterator = tmp_assign_source_3;
281  
282     // Tried code:
283     loop_start_1:;
284     tmp_next_source_1 = tmp_for_loop_1__for_iterator;
285  
286     CHECK_OBJECT( tmp_next_source_1 );
287     tmp_assign_source_4 = ITERATOR_NEXT( tmp_next_source_1 );
288     if ( tmp_assign_source_4 == NULL )
289     {
290         if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
291         {
292  
293             goto loop_end_1;
294         }
295         else
296         {
297  
298             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
299             type_description_1 = "oo";
300             exception_lineno = 34;
301             goto try_except_handler_2;
302         }
303     }
304  
305     {
306         PyObject *old = tmp_for_loop_1__iter_value;
307         tmp_for_loop_1__iter_value = tmp_assign_source_4;
308         Py_XDECREF( old );
309     }
310  
311     tmp_assign_source_5 = tmp_for_loop_1__iter_value;
312  
313     CHECK_OBJECT( tmp_assign_source_5 );
314     {
315         PyObject *old = var_x;
316         var_x = tmp_assign_source_5;
317         Py_INCREF( var_x );
318         Py_XDECREF( old );
319     }
320  
321     if ( CONSIDER_THREADING() == false )
322     {
323         assert( ERROR_OCCURRED() );
324  
325         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
326  
327  
328         exception_lineno = 34;
329         type_description_1 = "oo";
330         goto try_except_handler_2; 257     goto try_except_handler_1;
331     } 258  
332     goto loop_start_1; 259     frame_no_exception_1:;
333     loop_end_1:; 260  
261     tmp_return_value = Py_None;
262     Py_INCREF( tmp_return_value );
334     goto try_end_1; 263     goto try_return_handler_1;
264     // tried codes exits in all cases
265     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
266     return NULL;
267     // Return handler code:
268     try_return_handler_1:;
269     CHECK_OBJECT( (PyObject *)var_local_value );
270     Py_DECREF( var_local_value );
271     var_local_value = NULL;
272  
273     goto function_return_exit;
335     // Exception handler code: 274     // Exception handler code:
n 336     try_except_handler_2:; n 275     try_except_handler_1:;
337     exception_keeper_type_1 = exception_type; 276     exception_keeper_type_1 = exception_type;
338     exception_keeper_value_1 = exception_value; 277     exception_keeper_value_1 = exception_value;
339     exception_keeper_tb_1 = exception_tb; 278     exception_keeper_tb_1 = exception_tb;
340     exception_keeper_lineno_1 = exception_lineno; 279     exception_keeper_lineno_1 = exception_lineno;
341     exception_type = NULL; 280     exception_type = NULL;
342     exception_value = NULL; 281     exception_value = NULL;
343     exception_tb = NULL; 282     exception_tb = NULL;
344     exception_lineno = 0; 283     exception_lineno = 0;
345 284
n 346     Py_XDECREF( tmp_for_loop_1__iter_value ); n
347     tmp_for_loop_1__iter_value = NULL;
348  
349     Py_XDECREF( tmp_for_loop_1__for_iterator );
350     tmp_for_loop_1__for_iterator = NULL;
351  
352     // Re-raise. 285     // Re-raise.
353     exception_type = exception_keeper_type_1; 286     exception_type = exception_keeper_type_1;
354     exception_value = exception_keeper_value_1; 287     exception_value = exception_keeper_value_1;
355     exception_tb = exception_keeper_tb_1; 288     exception_tb = exception_keeper_tb_1;
356     exception_lineno = exception_keeper_lineno_1; 289     exception_lineno = exception_keeper_lineno_1;
t 357   t
358     goto frame_exception_exit_1;
359     // End of try:
360     try_end_1:;
361  
362 #if 0
363     RESTORE_FRAME_EXCEPTION( frame_0f1310ef1b512d4da200175ea0fec3df );
364 #endif
365  
366     // Put the previous frame back on top.
367     popFrameStack();
368  
369     goto frame_no_exception_1;
370  
371     frame_exception_exit_1:;
372  
373 #if 0
374     RESTORE_FRAME_EXCEPTION( frame_0f1310ef1b512d4da200175ea0fec3df );
375 #endif
376  
377     if ( exception_tb == NULL )
378     {
379         exception_tb = MAKE_TRACEBACK( frame_0f1310ef1b512d4da200175ea0fec3df, exception_lineno );
380     }
381     else if ( exception_tb->tb_frame != &frame_0f1310ef1b512d4da200175ea0fec3df->m_frame )
382     {
383         exception_tb = ADD_TRACEBACK( exception_tb, frame_0f1310ef1b512d4da200175ea0fec3df, exception_lineno );
384     }
385  
386     // Attachs locals to frame if any.
387     Nuitka_Frame_AttachLocals(
388         (struct Nuitka_FrameObject *)frame_0f1310ef1b512d4da200175ea0fec3df,
389         type_description_1,
390         var_x,
391         var_local_value
392     );
393  
394  
395     // Release cached frame.
396     if ( frame_0f1310ef1b512d4da200175ea0fec3df == cache_frame_0f1310ef1b512d4da200175ea0fec3df )
397     {
398         Py_DECREF( frame_0f1310ef1b512d4da200175ea0fec3df );
399     }
400     cache_frame_0f1310ef1b512d4da200175ea0fec3df = NULL;
401  
402     assertFrameObject( frame_0f1310ef1b512d4da200175ea0fec3df );
403  
404     // Put the previous frame back on top.
405     popFrameStack();
406  
407     // Return the error.
408     goto try_except_handler_1;
409  
410     frame_no_exception_1:;
411  
412     Py_XDECREF( tmp_for_loop_1__iter_value );
413     tmp_for_loop_1__iter_value = NULL;
414  
415     Py_XDECREF( tmp_for_loop_1__for_iterator );
416     tmp_for_loop_1__for_iterator = NULL;
417  
418     tmp_return_value = Py_None;
419     Py_INCREF( tmp_return_value );
420     goto try_return_handler_1;
421     // tried codes exits in all cases
422     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
423     return NULL;
424     // Return handler code:
425     try_return_handler_1:;
426     Py_XDECREF( var_x );
427     var_x = NULL;
428  
429     Py_XDECREF( var_local_value );
430     var_local_value = NULL;
431  
432     goto function_return_exit;
433     // Exception handler code:
434     try_except_handler_1:;
435     exception_keeper_type_2 = exception_type;
436     exception_keeper_value_2 = exception_value;
437     exception_keeper_tb_2 = exception_tb;
438     exception_keeper_lineno_2 = exception_lineno;
439     exception_type = NULL;
440     exception_value = NULL;
441     exception_tb = NULL;
442     exception_lineno = 0;
443  
444     Py_XDECREF( var_x );
445     var_x = NULL;
446  
447     Py_XDECREF( var_local_value );
448     var_local_value = NULL;
449  
450     // Re-raise.
451     exception_type = exception_keeper_type_2;
452     exception_value = exception_keeper_value_2;
453     exception_tb = exception_keeper_tb_2;
454     exception_lineno = exception_keeper_lineno_2;
455 290
456     goto function_exception_exit; 291     goto function_exception_exit;
457     // End of try: 292     // End of try:
458 293
459     // Return statement must have exited already. 294     // Return statement must have exited already.