Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)4156461988.95192307692307257.00000000000006CPython 2.78900071242.31730769230768451.2015237119747Nuitka (master)8849524395.6826923076923451.5020423176223Nuitka (develop)8850334549.0480769230769451.4972266001598Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5007348788.95192307692307257.0CPython 3.57050012242.31730769230768469.32319155475204Nuitka (master)7050006395.6826923076923469.32322116507873Nuitka (develop)7050016549.0480769230769469.32317181453425Nuitka (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
213             goto frame_exception_exit_1; 213             goto frame_exception_exit_1;
214         } 214         }
215         assert(var_x == NULL); 215         assert(var_x == NULL);
216         var_x = tmp_assign_source_3; 216         var_x = tmp_assign_source_3;
217     } 217     }
n 218     { n
219         PyObject *tmp_value_name_2;
220         PyObject *tmp_next_value_1;
221         CHECK_OBJECT(var_gen);
222         tmp_value_name_2 = var_gen;
223         tmp_next_value_1 = ITERATOR_NEXT(tmp_value_name_2);
224         if (tmp_next_value_1 == NULL) {
225             if (!ERROR_OCCURRED()) {
226                 exception_type = PyExc_StopIteration;
227                 Py_INCREF(exception_type);
228                 exception_value = NULL;
229                 exception_tb = NULL;
230             } else {
231                 FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
232             }
233  
234  
235             type_description_1 = "ooo";
236             exception_lineno = 34;
237             goto frame_exception_exit_1;
238         }
239         Py_DECREF(tmp_next_value_1);
240     }
241 218
242 #if 0 219 #if 0
243     RESTORE_FRAME_EXCEPTION(frame_e7fe790c5f2c65a79045d742bc73b55a); 220     RESTORE_FRAME_EXCEPTION(frame_e7fe790c5f2c65a79045d742bc73b55a);
244 #endif 221 #endif
245 222
319     exception_tb = NULL; 296     exception_tb = NULL;
320     exception_lineno = 0; 297     exception_lineno = 0;
321 298
322     Py_XDECREF(var_gen); 299     Py_XDECREF(var_gen);
323     var_gen = NULL; 300     var_gen = NULL;
t 324   t
325     Py_XDECREF(var_x);
326     var_x = NULL;
327 301
328     CHECK_OBJECT((PyObject *)var_generator); 302     CHECK_OBJECT((PyObject *)var_generator);
329     Py_DECREF(var_generator); 303     Py_DECREF(var_generator);
330     var_generator = NULL; 304     var_generator = NULL;
331 305