Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4366014588.95192307692307257.0CPython 2.78400008242.31730769230768456.571538673226Nuitka (master)8398976395.6826923076923456.5773797687359Nuitka (develop)8400026549.0480769230769456.5714367936531Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5062278888.95192307692307257.0CPython 3.57047700242.31730769230768469.7120029574276Nuitka (master)7040620395.6826923076923469.74656401169193Nuitka (develop)7040882549.0480769230769469.7452850574239Nuitka (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
221             goto frame_exception_exit_1; 221             goto frame_exception_exit_1;
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     }
n 226     { n
227         PyObject *tmp_value_name_2;
228         PyObject *tmp_next_value_1;
229         CHECK_OBJECT( var_gen );
230         tmp_value_name_2 = var_gen;
231         tmp_next_value_1 = ITERATOR_NEXT( tmp_value_name_2 );
232         if ( tmp_next_value_1 == NULL )
233         {
234             if ( !ERROR_OCCURRED() )
235             {
236                 exception_type = PyExc_StopIteration;
237                 Py_INCREF( exception_type );
238                 exception_value = NULL;
239                 exception_tb = NULL;
240             }
241             else
242             {
243                 FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
244             }
245  
246  
247             type_description_1 = "ooo";
248             exception_lineno = 34;
249             goto frame_exception_exit_1;
250         }
251         Py_DECREF( tmp_next_value_1 );
252     }
253 226
254 #if 0 227 #if 0
255     RESTORE_FRAME_EXCEPTION( frame_09bc0fa40ff8560aea8658af4534a958 ); 228     RESTORE_FRAME_EXCEPTION( frame_09bc0fa40ff8560aea8658af4534a958 );
256 #endif 229 #endif
257 230
334     exception_tb = NULL; 307     exception_tb = NULL;
335     exception_lineno = 0; 308     exception_lineno = 0;
336 309
337     Py_XDECREF( var_gen ); 310     Py_XDECREF( var_gen );
338     var_gen = NULL; 311     var_gen = NULL;
t 339   t
340     Py_XDECREF( var_x );
341     var_x = NULL;
342 312
343     CHECK_OBJECT( (PyObject *)var_generator ); 313     CHECK_OBJECT( (PyObject *)var_generator );
344     Py_DECREF( var_generator ); 314     Py_DECREF( var_generator );
345     var_generator = NULL; 315     var_generator = NULL;
346 316