Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)17312315972.9230769230769266.1103057810259CPython 2.70194.46153846153845504.11538461538464Nuitka (historic)179702049316.0257.0658241406893Nuitka (master)179701726437.53846153846143257.06626819243206Nuitka (develop)179749929559.0769230769231257.0Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)22137844272.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)177621149316.0305.84441407995405Nuitka (master)177609542437.53846153846143305.85737048276957Nuitka (develop)176661933559.0769230769231306.9151463004348Nuitka (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;
88     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 87     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
89     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 ); 88     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 );
90     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 89     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
91     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 137 ], 3, 0 ); 90     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 137 ], 3, 0 );
92     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 91     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 93     const_str_plain_all = UNSTREAM_STRING( &constant_bin[ 1 ], 3, 1 ); n
94     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); 92     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
95     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 ); 93     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 );
96     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 ); 94     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     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 95     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 );
98     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 ); 96     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 );
158     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 156     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
159     PyObject *exception_keeper_type_1; 157     PyObject *exception_keeper_type_1;
160     PyObject *exception_keeper_value_1; 158     PyObject *exception_keeper_value_1;
161     PyTracebackObject *exception_keeper_tb_1; 159     PyTracebackObject *exception_keeper_tb_1;
162     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 160     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 163     PyObject *tmp_args_element_name_1; n
164     PyObject *tmp_assign_source_1; 161     PyObject *tmp_assign_source_1;
165     PyObject *tmp_assign_source_2; 162     PyObject *tmp_assign_source_2;
166     PyObject *tmp_assign_source_3; 163     PyObject *tmp_assign_source_3;
n 167     PyObject *tmp_called_name_1; n
168     PyObject *tmp_dircall_arg1_1; 164     PyObject *tmp_dircall_arg1_1;
169     PyObject *tmp_iter_arg_1; 165     PyObject *tmp_iter_arg_1;
170     PyObject *tmp_return_value; 166     PyObject *tmp_return_value;
171     PyObject *tmp_tuple_element_1; 167     PyObject *tmp_tuple_element_1;
n 172     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
173     PyObject *tmp_value_name_1; 168     PyObject *tmp_value_name_1;
174     PyObject *tmp_value_name_2; 169     PyObject *tmp_value_name_2;
175     static struct Nuitka_FrameObject *cache_frame_function = NULL; 170     static struct Nuitka_FrameObject *cache_frame_function = NULL;
176 171
177     struct Nuitka_FrameObject *frame_function; 172     struct Nuitka_FrameObject *frame_function;
257         goto frame_exception_exit_1; 252         goto frame_exception_exit_1;
258     } 253     }
259     assert( var_x == NULL ); 254     assert( var_x == NULL );
260     var_x = tmp_assign_source_2; 255     var_x = tmp_assign_source_2;
261 256
t 262     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all ); t
263     assert( tmp_called_name_1 != NULL );
264     tmp_args_element_name_1 = var_gen;
265  
266     if ( tmp_args_element_name_1 == NULL )
267     {
268  
269         exception_type = PyExc_UnboundLocalError;
270         Py_INCREF( exception_type );
271         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
272         exception_tb = NULL;
273         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
274         CHAIN_EXCEPTION( exception_value );
275  
276         exception_lineno = 32;
277         type_description = "ooo";
278         goto frame_exception_exit_1;
279     }
280  
281     frame_function->m_frame.f_lineno = 32;
282     {
283         PyObject *call_args[] = { tmp_args_element_name_1 };
284         tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
285     }
286  
287     if ( tmp_unused == NULL )
288     {
289         assert( ERROR_OCCURRED() );
290  
291         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
292  
293  
294         exception_lineno = 32;
295         type_description = "ooo";
296         goto frame_exception_exit_1;
297     }
298     Py_DECREF( tmp_unused );
299     tmp_value_name_2 = var_gen; 257     tmp_value_name_2 = var_gen;
300 258
301     if ( tmp_value_name_2 == NULL ) 259     if ( tmp_value_name_2 == NULL )
302     { 260     {
303 261