Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)17537382488.11538461538461263.81021803946254CPython 2.7180343896240.03846153846155257.0Nuitka (master)180343387391.96153846153845257.00069745488236Nuitka (develop)180343593543.8846153846154257.00041518434057Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)21762831688.11538461538461257.0CPython 3.5176453421240.03846153846155303.7537965713206Nuitka (master)176460504391.96153846153845303.7457538758598Nuitka (develop)176454539543.8846153846154303.7525270903768Nuitka (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
46 extern PyObject *const_int_0; 46 extern PyObject *const_int_0;
47 extern PyObject *const_str_plain_print; 47 extern PyObject *const_str_plain_print;
48 static PyObject *const_int_pos_50000; 48 static PyObject *const_int_pos_50000;
49 static PyObject *const_str_plain_gen; 49 static PyObject *const_str_plain_gen;
50 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 50 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
n 51 static PyObject *const_str_plain_all; n
52 static PyObject *const_str_plain_calledRepeatedly; 51 static PyObject *const_str_plain_calledRepeatedly;
53 static PyObject *const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple; 52 static PyObject *const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple;
54 static PyObject *const_str_angle_module; 53 static PyObject *const_str_angle_module;
55 static PyObject *const_str_digest_29f3a571f48431d38086553406781357; 54 static PyObject *const_str_digest_29f3a571f48431d38086553406781357;
56 static PyObject *const_str_plain_x; 55 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( &constant_bin[ 27 ], 3, 1 ); 91     const_str_plain_gen = UNSTREAM_STRING( &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( &constant_bin[ 72 ], 3, 0 ); 93     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 72 ], 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( &constant_bin[ 1 ], 3, 1 ); n
97     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); 95     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
98     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 ); 96     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 );
99     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen ); 97     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen );
100     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 );
101     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 99     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
169     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 167     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
170     PyObject *exception_keeper_type_1; 168     PyObject *exception_keeper_type_1;
171     PyObject *exception_keeper_value_1; 169     PyObject *exception_keeper_value_1;
172     PyTracebackObject *exception_keeper_tb_1; 170     PyTracebackObject *exception_keeper_tb_1;
173     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 171     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 174     PyObject *tmp_args_element_name_1; n
175     PyObject *tmp_assign_source_1; 172     PyObject *tmp_assign_source_1;
176     PyObject *tmp_assign_source_2; 173     PyObject *tmp_assign_source_2;
177     PyObject *tmp_assign_source_3; 174     PyObject *tmp_assign_source_3;
178     PyObject *tmp_assign_source_4; 175     PyObject *tmp_assign_source_4;
n 179     PyObject *tmp_called_name_1; n
180     PyObject *tmp_iter_arg_1; 176     PyObject *tmp_iter_arg_1;
181     PyObject *tmp_outline_return_value_1; 177     PyObject *tmp_outline_return_value_1;
182     PyObject *tmp_return_value; 178     PyObject *tmp_return_value;
183     PyObject *tmp_tuple_element_1; 179     PyObject *tmp_tuple_element_1;
n 184     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
185     PyObject *tmp_value_name_1; 180     PyObject *tmp_value_name_1;
186     PyObject *tmp_value_name_2; 181     PyObject *tmp_value_name_2;
187     static struct Nuitka_FrameObject *cache_frame_8323c5fdc882d929825f357edf69e8ed = NULL; 182     static struct Nuitka_FrameObject *cache_frame_8323c5fdc882d929825f357edf69e8ed = NULL;
188 183
189     struct Nuitka_FrameObject *frame_8323c5fdc882d929825f357edf69e8ed; 184     struct Nuitka_FrameObject *frame_8323c5fdc882d929825f357edf69e8ed;
305         goto frame_exception_exit_1; 300         goto frame_exception_exit_1;
306     } 301     }
307     assert( var_x == NULL ); 302     assert( var_x == NULL );
308     var_x = tmp_assign_source_3; 303     var_x = tmp_assign_source_3;
309 304
t 310     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all ); t
311     assert( tmp_called_name_1 != NULL );
312     tmp_args_element_name_1 = var_gen;
313  
314     if ( tmp_args_element_name_1 == NULL )
315     {
316  
317         exception_type = PyExc_UnboundLocalError;
318         Py_INCREF( exception_type );
319         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
320         exception_tb = NULL;
321         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
322         CHAIN_EXCEPTION( exception_value );
323  
324         exception_lineno = 32;
325         type_description_1 = "ooo";
326         goto frame_exception_exit_1;
327     }
328  
329     frame_8323c5fdc882d929825f357edf69e8ed->m_frame.f_lineno = 32;
330     {
331         PyObject *call_args[] = { tmp_args_element_name_1 };
332         tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
333     }
334  
335     if ( tmp_unused == NULL )
336     {
337         assert( ERROR_OCCURRED() );
338  
339         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
340  
341  
342         exception_lineno = 32;
343         type_description_1 = "ooo";
344         goto frame_exception_exit_1;
345     }
346     Py_DECREF( tmp_unused );
347     tmp_value_name_2 = var_gen; 305     tmp_value_name_2 = var_gen;
348 306
349     if ( tmp_value_name_2 == NULL ) 307     if ( tmp_value_name_2 == NULL )
350     { 308     {
351 309