Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4366028288.95192307692307257.0CPython 2.78399840242.31730769230768456.5726387323486Nuitka (master)8399486395.6826923076923456.5746423576608Nuitka (develop)8400074549.0480769230769456.57131430205743Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5062276988.95192307692307257.0CPython 3.57049938242.31730769230768469.70106523304077Nuitka (master)7050030395.6826923076923469.700616134427Nuitka (develop)7050216549.0480769230769469.69970817418607Nuitka (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
220             goto frame_exception_exit_1; 220             goto frame_exception_exit_1;
221         } 221         }
222         assert( var_x == NULL ); 222         assert( var_x == NULL );
223         var_x = tmp_assign_source_3; 223         var_x = tmp_assign_source_3;
224     } 224     }
n 225     { n
226         PyObject *tmp_value_name_2;
227         PyObject *tmp_next_value_1;
228         CHECK_OBJECT( var_gen );
229         tmp_value_name_2 = var_gen;
230         tmp_next_value_1 = ITERATOR_NEXT( tmp_value_name_2 );
231         if ( tmp_next_value_1 == NULL )
232         {
233             if ( !ERROR_OCCURRED() )
234             {
235                 exception_type = PyExc_StopIteration;
236                 Py_INCREF( exception_type );
237                 exception_value = NULL;
238                 exception_tb = NULL;
239             }
240             else
241             {
242                 FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
243             }
244  
245  
246             type_description_1 = "ooo";
247             exception_lineno = 34;
248             goto frame_exception_exit_1;
249         }
250         Py_DECREF( tmp_next_value_1 );
251     }
252 225
253 #if 0 226 #if 0
254     RESTORE_FRAME_EXCEPTION( frame_cabd374a2ca15385f7c7ee29bcf1f91d ); 227     RESTORE_FRAME_EXCEPTION( frame_cabd374a2ca15385f7c7ee29bcf1f91d );
255 #endif 228 #endif
256 229
333     exception_tb = NULL; 306     exception_tb = NULL;
334     exception_lineno = 0; 307     exception_lineno = 0;
335 308
336     Py_XDECREF( var_gen ); 309     Py_XDECREF( var_gen );
337     var_gen = NULL; 310     var_gen = NULL;
t 338   t
339     Py_XDECREF( var_x );
340     var_x = NULL;
341 311
342     CHECK_OBJECT( (PyObject *)var_generator ); 312     CHECK_OBJECT( (PyObject *)var_generator );
343     Py_DECREF( var_generator ); 313     Py_DECREF( var_generator );
344     var_generator = NULL; 314     var_generator = NULL;
345 315