Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4411117088.95192307692307257.0CPython 2.78399990242.31730769230768457.0577627111054Nuitka (master)8399954395.6826923076923457.0579643868679Nuitka (develop)8399930549.0480769230769457.0580988373763Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5027271188.95192307692307257.0CPython 3.57149858242.31730769230768468.97027557968164Nuitka (master)7149903395.6826923076923468.97005438229473Nuitka (develop)7149875549.0480769230769468.97019201622436Nuitka (factory)Construct GeneratorUsageTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
    def generator():
        yield 1
        yield 2
        yield 3

    gen = generator()

    x = next(gen)
# construct_begin
    next(gen)
# construct_end

    return x

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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
    def generator():
        yield 1
        yield 2
        yield 3

    gen = generator()

    x = next(gen)
# construct_begin



    return x

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
29 29
30     gen = generator() 30     gen = generator()
31 31
32     x = next(gen) 32     x = next(gen)
33 # construct_begin 33 # construct_begin
t 34     next(gen) t 34  
35 # construct_end 35  
36 36
37     return x 37     return x
38 38
39 import itertools 39 import itertools
40 for x in itertools.repeat(None, 50000): 40 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
222     } 222     }
223     assert( var_x == NULL ); 223     assert( var_x == NULL );
224     var_x = tmp_assign_source_3; 224     var_x = tmp_assign_source_3;
225 225
226     } 226     }
n 227     { n
228     PyObject *tmp_value_name_2;
229     PyObject *tmp_next_value_1;
230     if ( var_gen == NULL )
231     {
232  
233         exception_type = PyExc_UnboundLocalError;
234         Py_INCREF( exception_type );
235         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
236         exception_tb = NULL;
237         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
238         CHAIN_EXCEPTION( exception_value );
239  
240         exception_lineno = 34;
241         type_description_1 = "ooo";
242         goto frame_exception_exit_1;
243     }
244  
245     tmp_value_name_2 = var_gen;
246     tmp_next_value_1 = ITERATOR_NEXT( tmp_value_name_2 );
247     if ( tmp_next_value_1 == NULL )
248     {
249         if ( !ERROR_OCCURRED() )
250         {
251             exception_type = PyExc_StopIteration;
252             Py_INCREF( exception_type );
253             exception_value = NULL;
254             exception_tb = NULL;
255         }
256         else
257         {
258             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
259         }
260  
261  
262         type_description_1 = "ooo";
263         exception_lineno = 34;
264         goto frame_exception_exit_1;
265     }
266     Py_DECREF( tmp_next_value_1 );
267     }
268 227
269 #if 0 228 #if 0
270     RESTORE_FRAME_EXCEPTION( frame_297d7bfb00f7c40b6f314d040580194d ); 229     RESTORE_FRAME_EXCEPTION( frame_297d7bfb00f7c40b6f314d040580194d );
271 #endif 230 #endif
272 231
315     // Return the error. 274     // Return the error.
316     goto try_except_handler_1; 275     goto try_except_handler_1;
317 276
318     frame_no_exception_1:; 277     frame_no_exception_1:;
319     { 278     {
n 320     if ( var_x == NULL ) n 279     CHECK_OBJECT( var_x );
321     {
322  
323         exception_type = PyExc_UnboundLocalError;
324         Py_INCREF( exception_type );
325         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "x" );
326         exception_tb = NULL;
327         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
328         CHAIN_EXCEPTION( exception_value );
329  
330  
331  
332         goto try_except_handler_1;
333     }
334  
335     tmp_return_value = var_x; 280     tmp_return_value = var_x;
336     Py_INCREF( tmp_return_value ); 281     Py_INCREF( tmp_return_value );
337     goto try_return_handler_1; 282     goto try_return_handler_1;
338     } 283     }
339     // tried codes exits in all cases 284     // tried codes exits in all cases
371     exception_lineno = 0; 316     exception_lineno = 0;
372 317
373     { 318     {
374     Py_XDECREF( var_gen ); 319     Py_XDECREF( var_gen );
375     var_gen = NULL; 320     var_gen = NULL;
t 376   t
377     }
378     {
379     Py_XDECREF( var_x );
380     var_x = NULL;
381 321
382     } 322     }
383     { 323     {
384     Py_XDECREF( var_generator ); 324     Py_XDECREF( var_generator );
385     var_generator = NULL; 325     var_generator = NULL;