Construct GeneratorUsage

Performance Diagrams

Construct GeneratorUsage 004000000400000080000008000000120000001200000016000000160000002000000020000000240000002400000028000000280000003200000032000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3514630688.95192307692307257.0CPython 2.76950618242.31730769230768455.24525185137196Nuitka (master)7200000395.6826923076923453.4918348963681Nuitka (develop)7200000549.0480769230769453.4918348963681Nuitka (factory)Construct GeneratorUsageTicks Construct GeneratorUsage 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)2483861988.95192307692307257.0CPython 3.85851040242.31730769230768445.9043383410326Nuitka (master)5850000395.6826923076923445.91468513205183Nuitka (develop)5850000549.0480769230769445.91468513205183Nuitka (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
116     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 116     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
117     PyObject *exception_type = NULL; 117     PyObject *exception_type = NULL;
118     PyObject *exception_value = NULL; 118     PyObject *exception_value = NULL;
119     PyTracebackObject *exception_tb = NULL; 119     PyTracebackObject *exception_tb = NULL;
120     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 120     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 121     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; n
122     static struct Nuitka_FrameObject *cache_frame_4488cc635023f69d6abf25f98defaa20 = NULL; 121     static struct Nuitka_FrameObject *cache_frame_4488cc635023f69d6abf25f98defaa20 = NULL;
123     PyObject *tmp_return_value = NULL; 122     PyObject *tmp_return_value = NULL;
124     PyObject *exception_keeper_type_1; 123     PyObject *exception_keeper_type_1;
125     PyObject *exception_keeper_value_1; 124     PyObject *exception_keeper_value_1;
126     PyTracebackObject *exception_keeper_tb_1; 125     PyTracebackObject *exception_keeper_tb_1;
205             exception_lineno = 32; 204             exception_lineno = 32;
206             goto frame_exception_exit_1; 205             goto frame_exception_exit_1;
207         } 206         }
208         assert(var_x == NULL); 207         assert(var_x == NULL);
209         var_x = tmp_assign_source_3; 208         var_x = tmp_assign_source_3;
n 210     } n
211     {
212         PyObject *tmp_value_name_2;
213         PyObject *tmp_next_value_1;
214         CHECK_OBJECT(var_gen);
215         tmp_value_name_2 = var_gen;
216         tmp_next_value_1 = ITERATOR_NEXT(tmp_value_name_2);
217         if (tmp_next_value_1 == NULL) {
218             if (!ERROR_OCCURRED()) {
219                 exception_type = PyExc_StopIteration;
220                 Py_INCREF(exception_type);
221                 exception_value = NULL;
222                 exception_tb = NULL;
223             } else {
224                 FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
225             }
226  
227  
228             type_description_1 = "ooo";
229             exception_lineno = 34;
230             goto frame_exception_exit_1;
231         }
232         Py_DECREF(tmp_next_value_1);
233     } 209     }
234 210
235 #if 0 211 #if 0
236     RESTORE_FRAME_EXCEPTION(frame_4488cc635023f69d6abf25f98defaa20); 212     RESTORE_FRAME_EXCEPTION(frame_4488cc635023f69d6abf25f98defaa20);
237 #endif 213 #endif
315     CHECK_OBJECT(var_generator); 291     CHECK_OBJECT(var_generator);
316     Py_DECREF(var_generator); 292     Py_DECREF(var_generator);
317     var_generator = NULL; 293     var_generator = NULL;
318     Py_XDECREF(var_gen); 294     Py_XDECREF(var_gen);
319     var_gen = NULL; 295     var_gen = NULL;
t 320     Py_XDECREF(var_x); t
321     var_x = NULL;
322     // Re-raise. 296     // Re-raise.
323     exception_type = exception_keeper_type_1; 297     exception_type = exception_keeper_type_1;
324     exception_value = exception_keeper_value_1; 298     exception_value = exception_keeper_value_1;
325     exception_tb = exception_keeper_tb_1; 299     exception_tb = exception_keeper_tb_1;
326     exception_lineno = exception_keeper_lineno_1; 300     exception_lineno = exception_keeper_lineno_1;