Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19575349288.11538461538461257.0CPython 2.7100864070240.03846153846155376.7865528419873Nuitka (master)100864238391.96153846153845376.7863407620689Nuitka (develop)100864478543.8846153846154376.78603779075684Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23942549788.11538461538461257.0CPython 3.599881515240.03846153846155401.0258669806262Nuitka (master)99884495391.96153846153845401.02279126874345Nuitka (develop)99883985543.8846153846154401.02331764896496Nuitka (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
44 extern PyObject *const_int_0; 44 extern PyObject *const_int_0;
45 extern PyObject *const_str_plain_print; 45 extern PyObject *const_str_plain_print;
46 static PyObject *const_int_pos_50000; 46 static PyObject *const_int_pos_50000;
47 static PyObject *const_str_plain_gen; 47 static PyObject *const_str_plain_gen;
48 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 48 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
n 49 static PyObject *const_str_plain_all; n
50 static PyObject *const_str_plain_calledRepeatedly; 49 static PyObject *const_str_plain_calledRepeatedly;
51 static PyObject *const_str_angle_module; 50 static PyObject *const_str_angle_module;
52 static PyObject *const_str_plain_None; 51 static PyObject *const_str_plain_None;
53 static PyObject *const_str_digest_a1b6b19e636905513bd0a8589c939f41; 52 static PyObject *const_str_digest_a1b6b19e636905513bd0a8589c939f41;
54 static PyObject *const_str_plain_x; 53 static PyObject *const_str_plain_x;
91     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 90     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
92     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 ); 91     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 );
93     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 92     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
94     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 58 ], 3, 0 ); 93     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 58 ], 3, 0 );
95     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 94     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 96     const_str_plain_all = UNSTREAM_STRING_ASCII( &constant_bin[ 1 ], 3, 1 ); n
97     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 ); 95     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 );
98     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 8, 0 ); 96     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 8, 0 );
99     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 69 ], 4, 1 ); 97     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 69 ], 4, 1 );
100     const_str_digest_a1b6b19e636905513bd0a8589c939f41 = UNSTREAM_STRING_ASCII( &constant_bin[ 73 ], 75, 0 ); 98     const_str_digest_a1b6b19e636905513bd0a8589c939f41 = UNSTREAM_STRING_ASCII( &constant_bin[ 73 ], 75, 0 );
101     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 ); 99     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 );
287         } 285         }
288         assert( var_x == NULL ); 286         assert( var_x == NULL );
289         var_x = tmp_assign_source_3; 287         var_x = tmp_assign_source_3;
290     } 288     }
291     { 289     {
t 292         PyObject *tmp_called_name_1; t
293         PyObject *tmp_call_result_1;
294         PyObject *tmp_args_element_name_1;
295         tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all );
296         assert( tmp_called_name_1 != NULL );
297         CHECK_OBJECT( var_gen );
298         tmp_args_element_name_1 = var_gen;
299         frame_1c55c71497a397692d1deeb513402dce->m_frame.f_lineno = 32;
300         {
301             PyObject *call_args[] = { tmp_args_element_name_1 };
302             tmp_call_result_1 = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
303         }
304  
305         if ( tmp_call_result_1 == NULL )
306         {
307             assert( ERROR_OCCURRED() );
308  
309             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
310  
311  
312             exception_lineno = 32;
313             type_description_1 = "ooo";
314             goto frame_exception_exit_1;
315         }
316         Py_DECREF( tmp_call_result_1 );
317     }
318     {
319         PyObject *tmp_assign_source_4; 290         PyObject *tmp_assign_source_4;
320         PyObject *tmp_value_name_2; 291         PyObject *tmp_value_name_2;
321         CHECK_OBJECT( var_gen ); 292         CHECK_OBJECT( var_gen );
322         tmp_value_name_2 = var_gen; 293         tmp_value_name_2 = var_gen;
323         tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 ); 294         tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 );