Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)18925498988.11538461538461257.0CPython 2.7105524701240.03846153846155366.32891350661794Nuitka (master)101917928391.96153846153845371.0383750739185Nuitka (develop)101917910543.8846153846154371.03839857700785Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)21922723488.11538461538461257.0CPython 3.5102248567240.03846153846155388.85965885743923Nuitka (master)96249433391.96153846153845395.62194964914454Nuitka (develop)96248667543.8846153846154395.62281309289267Nuitka (factory)Construct GeneratorExpressionUsageTicks

Source Code with Construct

not_all = [1,1,1,1,1,1,1,1,0,1]

def calledRepeatedly():
    # We measure making a generator iterator step or not.
    gen = (x for x in not_all)

    # make sure it is started.
    x = next(gen)

    # This should abort.
# construct_begin
    all(gen)
# construct_end

    # make sure it is still running.
    y = next(gen)

    return x, y

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

not_all = [1,1,1,1,1,1,1,1,0,1]

def calledRepeatedly():
    # We measure making a generator iterator step or not.
    gen = (x for x in not_all)

    # make sure it is started.
    x = next(gen)

    # This should abort.
# construct_begin



    # make sure it is still running.
    y = next(gen)

    return x, y

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
27     # make sure it is started. 27     # make sure it is started.
28     x = next(gen) 28     x = next(gen)
29 29
30     # This should abort. 30     # This should abort.
31 # construct_begin 31 # construct_begin
t 32     all(gen) t 32  
33 # construct_end 33  
34 34
35     # make sure it is still running. 35     # make sure it is still running.
36     y = next(gen) 36     y = next(gen)
37 37
38     return x, y 38     return x, y

Context Diff of Generated Code


Construct
Baseline
275         } 275         }
276         assert(var_x == NULL); 276         assert(var_x == NULL);
277         var_x = tmp_assign_source_3; 277         var_x = tmp_assign_source_3;
278     } 278     }
279     { 279     {
t 280         PyObject *tmp_all_arg_1; t
281         PyObject *tmp_capi_result_1;
282         CHECK_OBJECT(var_gen);
283         tmp_all_arg_1 = var_gen;
284         tmp_capi_result_1 = BUILTIN_ALL(tmp_all_arg_1);
285         if (tmp_capi_result_1 == NULL) {
286             assert(ERROR_OCCURRED());
287  
288             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
289  
290  
291             exception_lineno = 32;
292             type_description_1 = "ooo";
293             goto frame_exception_exit_1;
294         }
295         Py_DECREF(tmp_capi_result_1);
296     }
297     {
298         PyObject *tmp_assign_source_4; 280         PyObject *tmp_assign_source_4;
299         PyObject *tmp_value_name_2; 281         PyObject *tmp_value_name_2;
300         CHECK_OBJECT(var_gen); 282         CHECK_OBJECT(var_gen);
301         tmp_value_name_2 = var_gen; 283         tmp_value_name_2 = var_gen;
302         tmp_assign_source_4 = ITERATOR_NEXT(tmp_value_name_2); 284         tmp_assign_source_4 = ITERATOR_NEXT(tmp_value_name_2);