Construct GeneratorExpressionUsage

Performance Diagrams

Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19936620588.11538461538461257.0CPython 2.7183256300240.03846153846155276.9683059131928Nuitka (master)183256232391.96153846153845276.96839019952483Nuitka (develop)183256204543.8846153846154276.96842490566155Nuitka (factory)Construct GeneratorExpressionUsageTicks Construct GeneratorExpressionUsage 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23637635488.11538461538461257.0CPython 3.5177835242240.03846153846155318.20074687205096Nuitka (master)177885049391.96153846153845318.14867704462Nuitka (develop)177871855543.8846153846154318.1624704733173Nuitka (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_plain_True; 51 static PyObject *const_str_plain_True;
53 static PyObject *const_str_angle_module; 52 static PyObject *const_str_angle_module;
54 static PyObject *const_str_plain_None; 53 static PyObject *const_str_plain_None;
55 static PyObject *const_str_plain_x; 54 static PyObject *const_str_plain_x;
90     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 89     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
91     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 ); 90     const_str_plain_gen = UNSTREAM_STRING( &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( &constant_bin[ 140 ], 3, 0 ); 92     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 140 ], 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( &constant_bin[ 1 ], 3, 1 ); n
96     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); 94     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 );
97     const_str_plain_True = UNSTREAM_STRING( &constant_bin[ 143 ], 4, 1 ); 95     const_str_plain_True = UNSTREAM_STRING( &constant_bin[ 143 ], 4, 1 );
98     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 147 ], 8, 0 ); 96     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 147 ], 8, 0 );
99     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 155 ], 4, 1 ); 97     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 155 ], 4, 1 );
100     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 );
163     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 161     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
164     PyObject *exception_type = NULL; 162     PyObject *exception_type = NULL;
165     PyObject *exception_value = NULL; 163     PyObject *exception_value = NULL;
166     PyTracebackObject *exception_tb = NULL; 164     PyTracebackObject *exception_tb = NULL;
167     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 165     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 168     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
169     static struct Nuitka_FrameObject *cache_frame_6c5696288ec414e7ce114f9eca2e90a3 = NULL; 166     static struct Nuitka_FrameObject *cache_frame_6c5696288ec414e7ce114f9eca2e90a3 = NULL;
170     PyObject *tmp_return_value = NULL; 167     PyObject *tmp_return_value = NULL;
171     PyObject *exception_keeper_type_1; 168     PyObject *exception_keeper_type_1;
172     PyObject *exception_keeper_value_1; 169     PyObject *exception_keeper_value_1;
173     PyTracebackObject *exception_keeper_tb_1; 170     PyTracebackObject *exception_keeper_tb_1;
298         goto frame_exception_exit_1; 295         goto frame_exception_exit_1;
299     } 296     }
300     assert( var_x == NULL ); 297     assert( var_x == NULL );
301     var_x = tmp_assign_source_3; 298     var_x = tmp_assign_source_3;
302 299
t 303     } t
304     {
305     PyObject *tmp_called_name_1;
306     PyObject *tmp_args_element_name_1;
307     tmp_called_name_1 = LOOKUP_BUILTIN( const_str_plain_all );
308     assert( tmp_called_name_1 != NULL );
309     tmp_args_element_name_1 = var_gen;
310  
311     if ( tmp_args_element_name_1 == NULL )
312     {
313  
314         exception_type = PyExc_UnboundLocalError;
315         Py_INCREF( exception_type );
316         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "gen" );
317         exception_tb = NULL;
318         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
319         CHAIN_EXCEPTION( exception_value );
320  
321         exception_lineno = 32;
322         type_description_1 = "ooo";
323         goto frame_exception_exit_1;
324     }
325  
326     frame_6c5696288ec414e7ce114f9eca2e90a3->m_frame.f_lineno = 32;
327     {
328         PyObject *call_args[] = { tmp_args_element_name_1 };
329         tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_1, call_args );
330     }
331  
332     if ( tmp_unused == NULL )
333     {
334         assert( ERROR_OCCURRED() );
335  
336         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
337  
338  
339         exception_lineno = 32;
340         type_description_1 = "ooo";
341         goto frame_exception_exit_1;
342     }
343     Py_DECREF( tmp_unused );
344     } 300     }
345     { 301     {
346     PyObject *tmp_assign_source_4; 302     PyObject *tmp_assign_source_4;
347     PyObject *tmp_value_name_2; 303     PyObject *tmp_value_name_2;
348     tmp_value_name_2 = var_gen; 304     tmp_value_name_2 = var_gen;