Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)17312315972.9230769230769266.0468914613896CPython 2.70194.46153846153845504.11538461538464Nuitka (historic)179702049316.0257.0Nuitka (master)179693812437.53846153846143257.0113270240067Nuitka (develop)179692024559.0769230769231257.01378577342075Nuitka (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)177614576437.53846153846143305.8517512416415Nuitka (develop)177634102559.0769230769231305.82995519431006Nuitka (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;
89     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 88     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
90     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 ); 89     const_str_plain_gen = UNSTREAM_STRING( &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( &constant_bin[ 55 ], 3, 0 ); 91     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 55 ], 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( &constant_bin[ 1 ], 3, 1 ); n
95     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); 93     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
96     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 ); 94     const_tuple_str_plain_gen_str_plain_x_str_plain_y_tuple = PyTuple_New( 3 );
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 ); 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 );
98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 96     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 );
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 ); 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 );
157     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 155     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
158     PyObject *exception_keeper_type_1; 156     PyObject *exception_keeper_type_1;
159     PyObject *exception_keeper_value_1; 157     PyObject *exception_keeper_value_1;
160     PyTracebackObject *exception_keeper_tb_1; 158     PyTracebackObject *exception_keeper_tb_1;
161     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 159     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 162     PyObject *tmp_args_element_name_1; n
163     PyObject *tmp_assign_source_1; 160     PyObject *tmp_assign_source_1;
164     PyObject *tmp_assign_source_2; 161     PyObject *tmp_assign_source_2;
165     PyObject *tmp_assign_source_3; 162     PyObject *tmp_assign_source_3;
n 166     PyObject *tmp_called_name_1; n
167     PyObject *tmp_dircall_arg1_1; 163     PyObject *tmp_dircall_arg1_1;
168     PyObject *tmp_frame_locals; 164     PyObject *tmp_frame_locals;
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 PyFrameObject *cache_frame_function = NULL; 170     static PyFrameObject *cache_frame_function = NULL;
176 171
177     PyFrameObject *frame_function; 172     PyFrameObject *frame_function;
258         goto frame_exception_exit_1; 253         goto frame_exception_exit_1;
259     } 254     }
260     assert( var_x == NULL ); 255     assert( var_x == NULL );
261     var_x = tmp_assign_source_2; 256     var_x = tmp_assign_source_2;
262 257
t 263     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all ); t
264     assert( tmp_called_name_1 != NULL );
265     tmp_args_element_name_1 = var_gen;
266  
267     if ( tmp_args_element_name_1 == NULL )
268     {
269  
270         exception_type = PyExc_UnboundLocalError;
271         Py_INCREF( exception_type );
272         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
273         exception_tb = NULL;
274         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
275         CHAIN_EXCEPTION( exception_value );
276  
277         exception_lineno = 32;
278         goto frame_exception_exit_1;
279     }
280  
281     frame_function->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         goto frame_exception_exit_1;
296     }
297     Py_DECREF( tmp_unused );
298     tmp_value_name_2 = var_gen; 258     tmp_value_name_2 = var_gen;
299 259
300     if ( tmp_value_name_2 == NULL ) 260     if ( tmp_value_name_2 == NULL )
301     { 261     {
302 262