Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19936620588.11538461538461257.0CPython 2.7100864214240.03846153846155379.0936988359996Nuitka (master)100863914391.96153846153845379.0940706874645Nuitka (develop)100864190543.8846153846154379.0937285841168Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23637635488.11538461538461257.0CPython 3.599884525240.03846153846155399.6929142844479Nuitka (master)99884876391.96153846153845399.69254733784544Nuitka (develop)99878944543.8846153846154399.69874883997005Nuitka (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
45 extern PyObject *const_int_0; 45 extern PyObject *const_int_0;
46 extern PyObject *const_str_plain_print; 46 extern PyObject *const_str_plain_print;
47 static PyObject *const_int_pos_50000; 47 static PyObject *const_int_pos_50000;
48 static PyObject *const_str_plain_gen; 48 static PyObject *const_str_plain_gen;
49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
n 50 static PyObject *const_str_plain_all; n
51 static PyObject *const_str_plain_calledRepeatedly; 50 static PyObject *const_str_plain_calledRepeatedly;
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;
55 extern PyObject *const_tuple_empty; 54 extern PyObject *const_tuple_empty;
90     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 89     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
91     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 ); 90     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 );
92     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 91     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
93     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 133 ], 3, 0 ); 92     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 133 ], 3, 0 );
94     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 93     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 95     const_str_plain_all = UNSTREAM_STRING_ASCII( &constant_bin[ 1 ], 3, 1 ); n
96     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 ); 94     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 );
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 );
100     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 148 ], 6, 1 ); 98     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 148 ], 6, 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     if ( var_gen == NULL )
309     {
310  
311         exception_type = PyExc_UnboundLocalError;
312         Py_INCREF( exception_type );
313         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
314         exception_tb = NULL;
315         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
316         CHAIN_EXCEPTION( exception_value );
317  
318         exception_lineno = 32;
319         type_description_1 = "ooo";
320         goto frame_exception_exit_1;
321     }
322  
323     tmp_args_element_name_1 = var_gen;
324     frame_fcbb8588139b63d6d9d1299e01041008->m_frame.f_lineno = 32;
325     {
326         PyObject *call_args[] = { tmp_args_element_name_1 };
327         tmp_call_result_1 = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
328     }
329  
330     if ( tmp_call_result_1 == NULL )
331     {
332         assert( ERROR_OCCURRED() );
333  
334         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
335  
336  
337         exception_lineno = 32;
338         type_description_1 = "ooo";
339         goto frame_exception_exit_1;
340     }
341     Py_DECREF( tmp_call_result_1 );
342     }
343     {
344     PyObject *tmp_assign_source_4; 301     PyObject *tmp_assign_source_4;
345     PyObject *tmp_value_name_2; 302     PyObject *tmp_value_name_2;
346     if ( var_gen == NULL ) 303     if ( var_gen == NULL )
347     { 304     {
348 305