Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4411117088.95192307692307257.0CPython 2.78400044242.31730769230768457.0574601974616Nuitka (master)8399858395.6826923076923457.05850218890134Nuitka (develop)8399894549.0480769230769457.0583005131388Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5027271188.95192307692307257.0CPython 3.57146439242.31730769230768468.98708166559175Nuitka (master)7050074395.6826923076923469.4607635809844Nuitka (develop)7054864549.0480769230769469.4372183480188Nuitka (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     CHECK_OBJECT( var_gen );
231     tmp_value_name_2 = var_gen;
232     tmp_next_value_1 = ITERATOR_NEXT( tmp_value_name_2 );
233     if ( tmp_next_value_1 == NULL )
234     {
235         if ( !ERROR_OCCURRED() )
236         {
237             exception_type = PyExc_StopIteration;
238             Py_INCREF( exception_type );
239             exception_value = NULL;
240             exception_tb = NULL;
241         }
242         else
243         {
244             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
245         }
246  
247  
248         type_description_1 = "ooo";
249         exception_lineno = 34;
250         goto frame_exception_exit_1;
251     }
252     Py_DECREF( tmp_next_value_1 );
253     }
254 227
255 #if 0 228 #if 0
256     RESTORE_FRAME_EXCEPTION( frame_ad0099fa888b14525477353d220c5857 ); 229     RESTORE_FRAME_EXCEPTION( frame_ad0099fa888b14525477353d220c5857 );
257 #endif 230 #endif
258 231
346     exception_lineno = 0; 319     exception_lineno = 0;
347 320
348     { 321     {
349     Py_XDECREF( var_gen ); 322     Py_XDECREF( var_gen );
350     var_gen = NULL; 323     var_gen = NULL;
t 351   t
352     }
353     {
354     Py_XDECREF( var_x );
355     var_x = NULL;
356 324
357     } 325     }
358     { 326     {
359     CHECK_OBJECT( (PyObject *)var_generator ); 327     CHECK_OBJECT( (PyObject *)var_generator );
360     Py_DECREF( var_generator ); 328     Py_DECREF( var_generator );