Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4156461988.95192307692307257.00000000000006CPython 2.78900021242.31730769230768451.2018209784847Nuitka (master)8849604395.6826923076923451.5015666912062Nuitka (develop)8848762549.0480769230769451.5065726592351Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5007348788.95192307692307257.0CPython 3.57049980242.31730769230768469.3233494764943Nuitka (master)7049992395.6826923076923469.3232902558409Nuitka (develop)7050042549.0480769230769469.3230435031187Nuitka (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
216             goto frame_exception_exit_1; 216             goto frame_exception_exit_1;
217         } 217         }
218         assert(var_x == NULL); 218         assert(var_x == NULL);
219         var_x = tmp_assign_source_3; 219         var_x = tmp_assign_source_3;
220     } 220     }
n 221     { n
222         PyObject *tmp_value_name_2;
223         PyObject *tmp_next_value_1;
224         CHECK_OBJECT(var_gen);
225         tmp_value_name_2 = var_gen;
226         tmp_next_value_1 = ITERATOR_NEXT( tmp_value_name_2 );
227         if (tmp_next_value_1 == NULL)
228         {
229             if (!ERROR_OCCURRED()) {
230                 exception_type = PyExc_StopIteration;
231                 Py_INCREF(exception_type);
232                 exception_value = NULL;
233                 exception_tb = NULL;
234             } else {
235                 FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
236             }
237  
238  
239             type_description_1 = "ooo";
240             exception_lineno = 34;
241             goto frame_exception_exit_1;
242         }
243         Py_DECREF(tmp_next_value_1);
244     }
245 221
246 #if 0 222 #if 0
247     RESTORE_FRAME_EXCEPTION(frame_fef5ffae43e3b108c03d211bb773ac8a); 223     RESTORE_FRAME_EXCEPTION(frame_fef5ffae43e3b108c03d211bb773ac8a);
248 #endif 224 #endif
249 225
323     exception_tb = NULL; 299     exception_tb = NULL;
324     exception_lineno = 0; 300     exception_lineno = 0;
325 301
326     Py_XDECREF(var_gen); 302     Py_XDECREF(var_gen);
327     var_gen = NULL; 303     var_gen = NULL;
t 328   t
329     Py_XDECREF(var_x);
330     var_x = NULL;
331 304
332     CHECK_OBJECT((PyObject *)var_generator); 305     CHECK_OBJECT((PyObject *)var_generator);
333     Py_DECREF(var_generator); 306     Py_DECREF(var_generator);
334     var_generator = NULL; 307     var_generator = NULL;
335 308