Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19936620588.11538461538461257.0CPython 2.7100864196240.03846153846155379.09372114708754Nuitka (master)100864226391.96153846153845379.093683961941Nuitka (develop)100871678543.8846153846154379.0844471715524Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23637635488.11538461538461257.0CPython 3.599885125240.03846153846155399.6922870252984Nuitka (master)99889647391.96153846153845399.6875595821751Nuitka (develop)99884451543.8846153846154399.69299164640967Nuitka (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_digest_0dbcf828072c2668716b372d51c15b05; 50 static PyObject *const_str_digest_0dbcf828072c2668716b372d51c15b05;
52 static PyObject *const_str_angle_module; 51 static PyObject *const_str_angle_module;
53 static PyObject *const_str_plain_None; 52 static PyObject *const_str_plain_None;
54 static PyObject *const_str_plain_x; 53 static PyObject *const_str_plain_x;
89     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 88     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
90     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 ); 89     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 );
91     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 90     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
92     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 58 ], 3, 0 ); 91     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 58 ], 3, 0 );
93     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 92     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 94     const_str_plain_all = UNSTREAM_STRING_ASCII( &constant_bin[ 1 ], 3, 1 ); n
95     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 ); 93     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 );
96     const_str_digest_0dbcf828072c2668716b372d51c15b05 = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 75, 0 ); 94     const_str_digest_0dbcf828072c2668716b372d51c15b05 = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 75, 0 );
97     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 136 ], 8, 0 ); 95     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 136 ], 8, 0 );
98     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 144 ], 4, 1 ); 96     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 144 ], 4, 1 );
99     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 ); 97     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 );
298     assert( var_x == NULL ); 296     assert( var_x == NULL );
299     var_x = tmp_assign_source_3; 297     var_x = tmp_assign_source_3;
300 298
301     } 299     }
302     { 300     {
t 303     PyObject *tmp_called_name_1; t
304     PyObject *tmp_call_result_1;
305     PyObject *tmp_args_element_name_1;
306     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all );
307     assert( tmp_called_name_1 != NULL );
308     CHECK_OBJECT( var_gen );
309     tmp_args_element_name_1 = var_gen;
310     frame_8dae639a113ca101343de216bfce24d0->m_frame.f_lineno = 32;
311     {
312         PyObject *call_args[] = { tmp_args_element_name_1 };
313         tmp_call_result_1 = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
314     }
315  
316     if ( tmp_call_result_1 == NULL )
317     {
318         assert( ERROR_OCCURRED() );
319  
320         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
321  
322  
323         exception_lineno = 32;
324         type_description_1 = "ooo";
325         goto frame_exception_exit_1;
326     }
327     Py_DECREF( tmp_call_result_1 );
328     }
329     {
330     PyObject *tmp_assign_source_4; 301     PyObject *tmp_assign_source_4;
331     PyObject *tmp_value_name_2; 302     PyObject *tmp_value_name_2;
332     CHECK_OBJECT( var_gen ); 303     CHECK_OBJECT( var_gen );
333     tmp_value_name_2 = var_gen; 304     tmp_value_name_2 = var_gen;
334     tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 ); 305     tmp_assign_source_4 = ITERATOR_NEXT( tmp_value_name_2 );