Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)18925498988.11538461538461257.0CPython 2.7105516708240.03846153846155366.3393501840322Nuitka (master)101925830391.96153846153845371.02805721767834Nuitka (develop)101925818543.8846153846154371.0280728864046Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)21922723488.11538461538461257.0CPython 3.5102248697240.03846153846155388.8595123199885Nuitka (master)96249463391.96153846153845395.6219158328098Nuitka (develop)96249587543.8846153846154395.621776058626Nuitka (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
279         } 279         }
280         assert(var_x == NULL); 280         assert(var_x == NULL);
281         var_x = tmp_assign_source_3; 281         var_x = tmp_assign_source_3;
282     } 282     }
283     { 283     {
t 284         PyObject *tmp_all_arg_1; t
285         PyObject *tmp_capi_result_1;
286         CHECK_OBJECT(var_gen);
287         tmp_all_arg_1 = var_gen;
288         tmp_capi_result_1 = BUILTIN_ALL( tmp_all_arg_1 );
289         if ( tmp_capi_result_1 == NULL )
290         {
291             assert(ERROR_OCCURRED());
292  
293             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
294  
295  
296             exception_lineno = 32;
297             type_description_1 = "ooo";
298             goto frame_exception_exit_1;
299         }
300         Py_DECREF(tmp_capi_result_1);
301     }
302     {
303         PyObject *tmp_assign_source_4; 284         PyObject *tmp_assign_source_4;
304         PyObject *tmp_value_name_2; 285         PyObject *tmp_value_name_2;
305         CHECK_OBJECT(var_gen); 286         CHECK_OBJECT(var_gen);
306         tmp_value_name_2 = var_gen; 287         tmp_value_name_2 = var_gen;
307         tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 ); 288         tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 );