Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)17312315972.9230769230769267.4192353451049CPython 2.70194.46153846153845504.11538461538464Nuitka (historic)180743946316.0257.0Nuitka (master)179893905437.53846153846143258.16218669174043Nuitka (develop)179944503559.0769230769231258.093008473009Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)22137844272.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)177225268316.0306.2863192839708Nuitka (master)176467911437.53846153846143307.1317248467498Nuitka (develop)176460941559.0769230769231307.13950516273366Nuitka (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

for x in xrange(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

for x in xrange(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 static PyObject *const_xrange_0_50000; 46 static PyObject *const_xrange_0_50000;
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_plain_x; 54 static PyObject *const_str_plain_x;
56 extern PyObject *const_tuple_empty; 55 extern PyObject *const_tuple_empty;
87     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 86     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
88     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 ); 87     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 );
89     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 88     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
90     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 137 ], 3, 0 ); 89     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 137 ], 3, 0 );
91     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 90     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 92     const_str_plain_all = UNSTREAM_STRING( &constant_bin[ 1 ], 3, 1 ); n
93     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); 91     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
94     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 ); 92     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 );
95     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 ); 93     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 );
96     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 94     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 );
97     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 ); 95     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 );
155     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 153     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
156     PyObject *exception_keeper_type_1; 154     PyObject *exception_keeper_type_1;
157     PyObject *exception_keeper_value_1; 155     PyObject *exception_keeper_value_1;
158     PyTracebackObject *exception_keeper_tb_1; 156     PyTracebackObject *exception_keeper_tb_1;
159     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 157     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 160     PyObject *tmp_args_element_name_1; n
161     PyObject *tmp_assign_source_1; 158     PyObject *tmp_assign_source_1;
162     PyObject *tmp_assign_source_2; 159     PyObject *tmp_assign_source_2;
163     PyObject *tmp_assign_source_3; 160     PyObject *tmp_assign_source_3;
164     PyObject *tmp_assign_source_4; 161     PyObject *tmp_assign_source_4;
n 165     PyObject *tmp_called_name_1; n
166     PyObject *tmp_iter_arg_1; 162     PyObject *tmp_iter_arg_1;
167     PyObject *tmp_outline_return_value_1; 163     PyObject *tmp_outline_return_value_1;
168     PyObject *tmp_return_value; 164     PyObject *tmp_return_value;
169     PyObject *tmp_tuple_element_1; 165     PyObject *tmp_tuple_element_1;
n 170     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
171     PyObject *tmp_value_name_1; 166     PyObject *tmp_value_name_1;
172     PyObject *tmp_value_name_2; 167     PyObject *tmp_value_name_2;
173     static struct Nuitka_FrameObject *cache_frame_b9dad79ddb5562bbe0cf486342efafb3 = NULL; 168     static struct Nuitka_FrameObject *cache_frame_b9dad79ddb5562bbe0cf486342efafb3 = NULL;
174 169
175     struct Nuitka_FrameObject *frame_b9dad79ddb5562bbe0cf486342efafb3; 170     struct Nuitka_FrameObject *frame_b9dad79ddb5562bbe0cf486342efafb3;
291         goto frame_exception_exit_1; 286         goto frame_exception_exit_1;
292     } 287     }
293     assert( var_x == NULL ); 288     assert( var_x == NULL );
294     var_x = tmp_assign_source_3; 289     var_x = tmp_assign_source_3;
295 290
t 296     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all ); t
297     assert( tmp_called_name_1 != NULL );
298     tmp_args_element_name_1 = var_gen;
299  
300     if ( tmp_args_element_name_1 == NULL )
301     {
302  
303         exception_type = PyExc_UnboundLocalError;
304         Py_INCREF( exception_type );
305         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
306         exception_tb = NULL;
307         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
308         CHAIN_EXCEPTION( exception_value );
309  
310         exception_lineno = 32;
311         type_description = "ooo";
312         goto frame_exception_exit_1;
313     }
314  
315     frame_b9dad79ddb5562bbe0cf486342efafb3->m_frame.f_lineno = 32;
316     {
317         PyObject *call_args[] = { tmp_args_element_name_1 };
318         tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
319     }
320  
321     if ( tmp_unused == NULL )
322     {
323         assert( ERROR_OCCURRED() );
324  
325         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
326  
327  
328         exception_lineno = 32;
329         type_description = "ooo";
330         goto frame_exception_exit_1;
331     }
332     Py_DECREF( tmp_unused );
333     tmp_value_name_2 = var_gen; 291     tmp_value_name_2 = var_gen;
334 292
335     if ( tmp_value_name_2 == NULL ) 293     if ( tmp_value_name_2 == NULL )
336     { 294     {
337 295