Construct LoopSmallRange

Performance Diagrams

Construct LoopSmallRange 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)11002546972.9230769230769257.0CPython 2.754807241194.46153846153845381.0192273118145Nuitka (historic)52260907316.0386.738251384043Nuitka (master)52256670437.53846153846143386.74776761600396Nuitka (develop)52257745559.0769230769231386.74535318377406Nuitka (factory)Construct LoopSmallRangeTicks Construct LoopSmallRange 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14521802672.9230769230769257.00000000000006CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)87027568316.0356.02184877251665Nuitka (master)87026800437.53846153846143356.0231556668507Nuitka (develop)87033108559.0769230769231356.0124214357839Nuitka (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

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




for x in xrange(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 for x in xrange(50000): 38 for x in xrange(50000):
39     calledRepeatedly() 39     calledRepeatedly()
40 40
41 print("OK.") 41 print("OK.")

Context Diff of Generated Code


Construct
Baseline
49 static PyObject *const_str_angle_module; 49 static PyObject *const_str_angle_module;
50 static PyObject *const_str_plain_x; 50 static PyObject *const_str_plain_x;
51 extern PyObject *const_tuple_empty; 51 extern PyObject *const_tuple_empty;
52 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 52 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
53 static PyObject *const_int_pos_5; 53 static PyObject *const_int_pos_5;
n 54 static PyObject *const_int_pos_2; n
55 static PyObject *const_tuple_str_plain_x_str_plain_local_value_tuple; 54 static PyObject *const_tuple_str_plain_x_str_plain_local_value_tuple;
56 extern PyObject *const_str_plain___loader__; 55 extern PyObject *const_str_plain___loader__;
57 extern PyObject *const_str_plain___main__; 56 extern PyObject *const_str_plain___main__;
58 extern PyObject *const_str_plain___doc__; 57 extern PyObject *const_str_plain___doc__;
59 extern PyObject *const_str_plain___cached__; 58 extern PyObject *const_str_plain___cached__;
76     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 110 ], 13, 1 ); 75     const_str_plain_module_value1 = UNSTREAM_STRING( &constant_bin[ 110 ], 13, 1 );
77     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 123 ], 16, 1 ); 76     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 123 ], 16, 1 );
78     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 139 ], 8, 0 ); 77     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 139 ], 8, 0 );
79     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 63 ], 1, 1 ); 78     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 63 ], 1, 1 );
80     const_int_pos_5 = PyLong_FromUnsignedLong( 5ul ); 79     const_int_pos_5 = PyLong_FromUnsignedLong( 5ul );
n 81     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul ); n
82     const_tuple_str_plain_x_str_plain_local_value_tuple = PyTuple_New( 2 ); 80     const_tuple_str_plain_x_str_plain_local_value_tuple = PyTuple_New( 2 );
83     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 0, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 81     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 0, const_str_plain_x ); Py_INCREF( const_str_plain_x );
84     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 1, const_str_plain_local_value ); Py_INCREF( const_str_plain_local_value ); 82     PyTuple_SET_ITEM( const_tuple_str_plain_x_str_plain_local_value_tuple, 1, const_str_plain_local_value ); Py_INCREF( const_str_plain_local_value );
85 83
86     constants_created = true; 84     constants_created = true;
121 #ifndef __NUITKA_NO_ASSERT__ 119 #ifndef __NUITKA_NO_ASSERT__
122     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 120     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
123 #endif 121 #endif
124 122
125     // Local variable declarations. 123     // Local variable declarations.
n 126     PyObject *var_x = NULL; n
127     PyObject *var_local_value = NULL; 124     PyObject *var_local_value = NULL;
n 128     PyObject *tmp_for_loop_1__for_iterator = NULL; n
129     PyObject *tmp_for_loop_1__iter_value = NULL;
130     PyObject *exception_type = NULL, *exception_value = NULL; 125     PyObject *exception_type = NULL, *exception_value = NULL;
131     PyTracebackObject *exception_tb = NULL; 126     PyTracebackObject *exception_tb = NULL;
132     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 127     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
133     PyObject *exception_keeper_type_1; 128     PyObject *exception_keeper_type_1;
134     PyObject *exception_keeper_value_1; 129     PyObject *exception_keeper_value_1;
135     PyTracebackObject *exception_keeper_tb_1; 130     PyTracebackObject *exception_keeper_tb_1;
136     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 131     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 137     PyObject *exception_keeper_type_2; n
138     PyObject *exception_keeper_value_2;
139     PyTracebackObject *exception_keeper_tb_2;
140     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
141     PyObject *tmp_assign_source_1; 132     PyObject *tmp_assign_source_1;
n 142     PyObject *tmp_assign_source_2; n
143     PyObject *tmp_assign_source_3;
144     PyObject *tmp_assign_source_4;
145     PyObject *tmp_assign_source_5;
146     PyObject *tmp_frame_locals; 133     PyObject *tmp_frame_locals;
n 147     PyObject *tmp_iter_arg_1; n
148     PyObject *tmp_left_name_1;
149     PyObject *tmp_next_source_1;
150     PyObject *tmp_return_value; 134     PyObject *tmp_return_value;
n 151     PyObject *tmp_right_name_1; n
152     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 135     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
n 153     PyObject *tmp_xrange_high_1; n
154     PyObject *tmp_xrange_low_1;
155     static PyFrameObject *cache_frame_function = NULL; 136     static PyFrameObject *cache_frame_function = NULL;
156 137
157     PyFrameObject *frame_function; 138     PyFrameObject *frame_function;
158 139
159     tmp_return_value = NULL; 140     tmp_return_value = NULL;
194 175
195         exception_lineno = 26; 176         exception_lineno = 26;
196         goto frame_exception_exit_1; 177         goto frame_exception_exit_1;
197     } 178     }
198 179
n 199     tmp_assign_source_1 = const_int_pos_2; n
200     assert( var_x == NULL );
201     Py_INCREF( tmp_assign_source_1 );
202     var_x = tmp_assign_source_1;
203  
204     tmp_assign_source_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 ); 180     tmp_assign_source_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
205 181
n 206     if (unlikely( tmp_assign_source_2 == NULL )) n 182     if (unlikely( tmp_assign_source_1 == NULL ))
207     { 183     {
n 208         tmp_assign_source_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 ); n 184         tmp_assign_source_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
209     } 185     }
210 186
n 211     if ( tmp_assign_source_2 == NULL ) n 187     if ( tmp_assign_source_1 == NULL )
212     { 188     {
213 189
214         exception_type = PyExc_NameError; 190         exception_type = PyExc_NameError;
215         Py_INCREF( exception_type ); 191         Py_INCREF( exception_type );
216         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" ); 192         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
221         exception_lineno = 31; 197         exception_lineno = 31;
222         goto frame_exception_exit_1; 198         goto frame_exception_exit_1;
223     } 199     }
224 200
225     assert( var_local_value == NULL ); 201     assert( var_local_value == NULL );
n 226     Py_INCREF( tmp_assign_source_2 ); n 202     Py_INCREF( tmp_assign_source_1 );
227     var_local_value = tmp_assign_source_2; 203     var_local_value = tmp_assign_source_1;
228 204
n 229     tmp_xrange_low_1 = var_local_value; n
230  
231     tmp_left_name_1 = var_local_value;
232  
233     tmp_right_name_1 = const_int_pos_3;
234     tmp_xrange_high_1 = BINARY_OPERATION_ADD( tmp_left_name_1, tmp_right_name_1 );
235     if ( tmp_xrange_high_1 == NULL )
236     {
237         assert( ERROR_OCCURRED() );
238  
239         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
240  
241  
242         exception_lineno = 34;
243         goto frame_exception_exit_1;
244     }
245     tmp_iter_arg_1 = BUILTIN_XRANGE2( tmp_xrange_low_1, tmp_xrange_high_1 );
246     Py_DECREF( tmp_xrange_high_1 );
247     if ( tmp_iter_arg_1 == NULL )
248     {
249         assert( ERROR_OCCURRED() );
250  
251         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
252  
253  
254         exception_lineno = 34;
255         goto frame_exception_exit_1;
256     }
257     tmp_assign_source_3 = MAKE_ITERATOR( tmp_iter_arg_1 );
258     Py_DECREF( tmp_iter_arg_1 );
259     if ( tmp_assign_source_3 == NULL )
260     {
261         assert( ERROR_OCCURRED() );
262  
263         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
264  
265  
266         exception_lineno = 34;
267         goto frame_exception_exit_1;
268     }
269     assert( tmp_for_loop_1__for_iterator == NULL );
270     tmp_for_loop_1__for_iterator = tmp_assign_source_3;
271  
272     // Tried code:
273     loop_start_1:;
274     tmp_next_source_1 = tmp_for_loop_1__for_iterator;
275  
276     tmp_assign_source_4 = ITERATOR_NEXT( tmp_next_source_1 );
277     if ( tmp_assign_source_4 == NULL )
278     {
279         if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
280         {
281  
282             goto loop_end_1;
283         }
284         else
285         {
286  
287             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
288             frame_function->f_lineno = 34;
289             goto try_except_handler_2;
290         }
291     }
292  
293     {
294         PyObject *old = tmp_for_loop_1__iter_value;
295         tmp_for_loop_1__iter_value = tmp_assign_source_4;
296         Py_XDECREF( old );
297     }
298  
299     tmp_assign_source_5 = tmp_for_loop_1__iter_value;
300  
301     {
302         PyObject *old = var_x;
303         var_x = tmp_assign_source_5;
304         Py_INCREF( var_x );
305         Py_XDECREF( old );
306     }
307  
308     if ( CONSIDER_THREADING() == false )
309     {
310         assert( ERROR_OCCURRED() );
311  
312         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
313  
314  
315         exception_lineno = 34;
316         goto try_except_handler_2;
317     }
318     goto loop_start_1;
319     loop_end_1:;
320     goto try_end_1;
321     // Exception handler code:
322     try_except_handler_2:;
323     exception_keeper_type_1 = exception_type;
324     exception_keeper_value_1 = exception_value;
325     exception_keeper_tb_1 = exception_tb;
326     exception_keeper_lineno_1 = exception_lineno;
327     exception_type = NULL;
328     exception_value = NULL;
329     exception_tb = NULL;
330     exception_lineno = -1;
331  
332     Py_XDECREF( tmp_for_loop_1__iter_value );
333     tmp_for_loop_1__iter_value = NULL;
334  
335     Py_XDECREF( tmp_for_loop_1__for_iterator );
336     tmp_for_loop_1__for_iterator = NULL;
337  
338     // Re-raise.
339     exception_type = exception_keeper_type_1;
340     exception_value = exception_keeper_value_1;
341     exception_tb = exception_keeper_tb_1;
342     exception_lineno = exception_keeper_lineno_1;
343  
344     goto frame_exception_exit_1;
345     // End of try:
346     try_end_1:;
347 205
348 #if 0 206 #if 0
349     RESTORE_FRAME_EXCEPTION( frame_function ); 207     RESTORE_FRAME_EXCEPTION( frame_function );
350 #endif 208 #endif
351     // Put the previous frame back on top. 209     // Put the previous frame back on top.
380 238
381         if (needs_detach) 239         if (needs_detach)
382         { 240         {
383 241
384             tmp_frame_locals = PyDict_New(); 242             tmp_frame_locals = PyDict_New();
n 385             if ( var_x ) n
386             {
387                 int res = PyDict_SetItem(
388                     tmp_frame_locals,
389                     const_str_plain_x,
390                     var_x
391                 );
392  
393                 assert( res == 0 );
394             }
395  
396             if ( var_local_value ) 243             if ( var_local_value )
397             { 244             {
398                 int res = PyDict_SetItem( 245                 int res = PyDict_SetItem(
399                     tmp_frame_locals, 246                     tmp_frame_locals,
400                     const_str_plain_local_value, 247                     const_str_plain_local_value,
419 266
420     // Return the error. 267     // Return the error.
421     goto try_except_handler_1; 268     goto try_except_handler_1;
422 269
423     frame_no_exception_1:; 270     frame_no_exception_1:;
n 424   n
425     Py_XDECREF( tmp_for_loop_1__iter_value );
426     tmp_for_loop_1__iter_value = NULL;
427  
428     Py_XDECREF( tmp_for_loop_1__for_iterator );
429     tmp_for_loop_1__for_iterator = NULL;
430 271
431     tmp_return_value = Py_None; 272     tmp_return_value = Py_None;
432     Py_INCREF( tmp_return_value ); 273     Py_INCREF( tmp_return_value );
433     goto try_return_handler_1; 274     goto try_return_handler_1;
434     // tried codes exits in all cases 275     // tried codes exits in all cases
435     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 276     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
436     return NULL; 277     return NULL;
437     // Return handler code: 278     // Return handler code:
438     try_return_handler_1:; 279     try_return_handler_1:;
n 439     Py_XDECREF( var_x ); n 280     CHECK_OBJECT( (PyObject *)var_local_value );
440     var_x = NULL;
441  
442     Py_XDECREF( var_local_value ); 281     Py_DECREF( var_local_value );
443     var_local_value = NULL; 282     var_local_value = NULL;
444 283
445     goto function_return_exit; 284     goto function_return_exit;
446     // Exception handler code: 285     // Exception handler code:
447     try_except_handler_1:; 286     try_except_handler_1:;
n 448     exception_keeper_type_2 = exception_type; n 287     exception_keeper_type_1 = exception_type;
449     exception_keeper_value_2 = exception_value; 288     exception_keeper_value_1 = exception_value;
450     exception_keeper_tb_2 = exception_tb; 289     exception_keeper_tb_1 = exception_tb;
451     exception_keeper_lineno_2 = exception_lineno; 290     exception_keeper_lineno_1 = exception_lineno;
452     exception_type = NULL; 291     exception_type = NULL;
453     exception_value = NULL; 292     exception_value = NULL;
454     exception_tb = NULL; 293     exception_tb = NULL;
455     exception_lineno = -1; 294     exception_lineno = -1;
456 295
n 457     Py_XDECREF( var_x ); n
458     var_x = NULL;
459  
460     Py_XDECREF( var_local_value );
461     var_local_value = NULL;
462  
463     // Re-raise. 296     // Re-raise.
t 464     exception_type = exception_keeper_type_2; t 297     exception_type = exception_keeper_type_1;
465     exception_value = exception_keeper_value_2; 298     exception_value = exception_keeper_value_1;
466     exception_tb = exception_keeper_tb_2; 299     exception_tb = exception_keeper_tb_1;
467     exception_lineno = exception_keeper_lineno_2; 300     exception_lineno = exception_keeper_lineno_1;
468 301
469     goto function_exception_exit; 302     goto function_exception_exit;
470     // End of try: 303     // End of try:
471 304
472     // Return statement must have exited already. 305     // Return statement must have exited already.