Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)23540249888.11538461538461257.0CPython 2.745180172240.03846153846155456.6871896063018Nuitka (master)45180003391.96153846153845456.68736701520936Nuitka (develop)45180027543.8846153846154456.6873418210449Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23509232188.11538461538461257.0CPython 3.558083523240.03846153846155443.0613609666856Nuitka (master)58083052391.96153846153845443.0618560545118Nuitka (develop)58084255543.8846153846154443.0605915308284Nuitka (factory)Construct GeneratorExpressionCreationTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
# construct_begin
    gen = (x for x in range(3))
# construct_alternative



    x = next(gen)
    next(gen)

    return x

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
# construct_begin

# construct_alternative
    gen = iter((1,2,3))
# construct_end

    x = next(gen)
    next(gen)

    return x

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
19 # 19 #
20 20
21 def calledRepeatedly(): 21 def calledRepeatedly():
22     # We measure making a generator iterator step or not. 22     # We measure making a generator iterator step or not.
23 # construct_begin 23 # construct_begin
n 24     gen = (x for x in range(3)) n 24  
25 # construct_alternative 25 # construct_alternative
t 26   t 26     gen = iter((1,2,3))
27   27 # construct_end
28 28
29     x = next(gen) 29     x = next(gen)
30     next(gen) 30     next(gen)
31 31
32     return x 32     return x

Context Diff of Generated Code


Construct
Baseline
29 29
30 PyObject *module___main__; 30 PyObject *module___main__;
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
32 32
33 /* The module constants used, if any. */ 33 /* The module constants used, if any. */
n 34 static PyObject *const_str_digest_57aac74124c55d29a6f122835861daff; n
35 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
n 36 static PyObject *const_str_plain_False; n
37 static PyObject *const_str_angle_genexpr;
38 static PyObject *const_xrange_0_3;
39 extern PyObject *const_int_pos_1; 35 extern PyObject *const_int_pos_1;
40 extern PyObject *const_str_plain___file__; 36 extern PyObject *const_str_plain___file__;
n 41 static PyObject *const_str_digest_b9c4baf879ebd882d40843df3a4dead7; n
42 extern PyObject *const_int_0; 37 extern PyObject *const_int_0;
43 extern PyObject *const_str_plain_print; 38 extern PyObject *const_str_plain_print;
n n 39 static PyObject *const_int_pos_50000;
40 static PyObject *const_str_plain_gen;
44 static PyObject *const_int_pos_3; 41 static PyObject *const_int_pos_3;
n 45 static PyObject *const_str_plain_gen; n
46 static PyObject *const_int_pos_50000;
47 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
48 static PyObject *const_str_plain_calledRepeatedly; 43 static PyObject *const_str_plain_calledRepeatedly;
49 static PyObject *const_str_angle_module; 44 static PyObject *const_str_angle_module;
50 static PyObject *const_str_plain_None; 45 static PyObject *const_str_plain_None;
51 static PyObject *const_str_plain_x; 46 static PyObject *const_str_plain_x;
52 extern PyObject *const_tuple_empty; 47 extern PyObject *const_tuple_empty;
53 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 48 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
54 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple; 49 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple;
55 static PyObject *const_str_plain_repeat; 50 static PyObject *const_str_plain_repeat;
56 static PyObject *const_str_digest_573e9eae55bb76c8b093f71b2000b21c; 51 static PyObject *const_str_digest_573e9eae55bb76c8b093f71b2000b21c;
n 57 static PyObject *const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple; n 52 static PyObject *const_int_pos_2;
58 static PyObject *const_tuple_none_int_pos_50000_tuple; 53 static PyObject *const_tuple_none_int_pos_50000_tuple;
59 extern PyObject *const_str_plain___main__; 54 extern PyObject *const_str_plain___main__;
n n 55 static PyObject *const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
60 extern PyObject *const_str_plain___doc__; 56 extern PyObject *const_str_plain___doc__;
61 extern PyObject *const_str_plain___cached__; 57 extern PyObject *const_str_plain___cached__;
62 static PyObject *const_str_plain___debug__; 58 static PyObject *const_str_plain___debug__;
63 static PyObject *module_filename_obj; 59 static PyObject *module_filename_obj;
64 60
65 static bool constants_created = false; 61 static bool constants_created = false;
66 62
67 static void createModuleConstants( void ) 63 static void createModuleConstants( void )
68 { 64 {
n 69     const_str_digest_57aac74124c55d29a6f122835861daff = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 35, 0 ); n
70     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 35 ], 9, 1 ); 65     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 );
66     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
71     const_str_plain_False = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 5, 1 ); 67     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 3, 1 );
72     const_str_angle_genexpr = UNSTREAM_STRING_ASCII( &constant_bin[ 26 ], 9, 0 );
73     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul ); 68     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul );
n 74     const_xrange_0_3 = BUILTIN_XRANGE3( const_int_0, const_int_pos_3, const_int_pos_1 ); n
75     const_str_digest_b9c4baf879ebd882d40843df3a4dead7 = UNSTREAM_STRING_ASCII( &constant_bin[ 49 ], 2, 1 );
76     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 );
77     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
78     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 69     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 79     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 51 ], 3, 0 ); n 70     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 12 ], 3, 0 );
80     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 71     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 81     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 ); n 72     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 15 ], 16, 1 );
82     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 54 ], 8, 0 ); 73     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 8, 0 );
83     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 62 ], 4, 1 ); 74     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 39 ], 4, 1 );
84     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 ); 75     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 43 ], 1, 1 );
85     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 ); 76     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 );
86     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen ); 77     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen );
87     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 78     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
n 88     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 66 ], 6, 1 ); n 79     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 6, 1 );
89     const_str_digest_573e9eae55bb76c8b093f71b2000b21c = UNSTREAM_STRING_ASCII( &constant_bin[ 72 ], 78, 0 ); 80     const_str_digest_573e9eae55bb76c8b093f71b2000b21c = UNSTREAM_STRING_ASCII( &constant_bin[ 50 ], 78, 0 );
90     const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple = PyTuple_New( 2 ); 81     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul );
91     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 0, const_str_digest_b9c4baf879ebd882d40843df3a4dead7 ); Py_INCREF( const_str_digest_b9c4baf879ebd882d40843df3a4dead7 );
92     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
93     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 82     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
94     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 83     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
95     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 84     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n n 85     const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple = PyTuple_New( 3 );
86     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 0, const_int_pos_1 ); Py_INCREF( const_int_pos_1 );
87     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 1, const_int_pos_2 ); Py_INCREF( const_int_pos_2 );
88     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 2, const_int_pos_3 ); Py_INCREF( const_int_pos_3 );
96     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 150 ], 9, 1 ); 89     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 128 ], 9, 1 );
97 90
98     constants_created = true; 91     constants_created = true;
99 } 92 }
100 93
101 #ifndef __NUITKA_NO_ASSERT__ 94 #ifndef __NUITKA_NO_ASSERT__
107 100
108 } 101 }
109 #endif 102 #endif
110 103
111 // The module code objects. 104 // The module code objects.
n 112 static PyCodeObject *codeobj_5f736bdec5dac2f9cd911385793d0797; n
113 static PyCodeObject *codeobj_3c4826f777a832afc300183846e870f0; 105 static PyCodeObject *codeobj_3c4826f777a832afc300183846e870f0;
114 static PyCodeObject *codeobj_35a40ff95ecc1505443ba63870ed0939; 106 static PyCodeObject *codeobj_35a40ff95ecc1505443ba63870ed0939;
115 /* For use in "MainProgram.c". */ 107 /* For use in "MainProgram.c". */
116 PyCodeObject *codeobj_main = NULL; 108 PyCodeObject *codeobj_main = NULL;
117 109
118 static void createModuleCodeObjects(void) 110 static void createModuleCodeObjects(void)
119 { 111 {
120     module_filename_obj = const_str_digest_573e9eae55bb76c8b093f71b2000b21c; 112     module_filename_obj = const_str_digest_573e9eae55bb76c8b093f71b2000b21c;
n 121     codeobj_5f736bdec5dac2f9cd911385793d0797 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_genexpr, 24, const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, 0, CO_GENERATOR | CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); n
122     codeobj_3c4826f777a832afc300183846e870f0 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 113     codeobj_3c4826f777a832afc300183846e870f0 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
123     codeobj_main = codeobj_3c4826f777a832afc300183846e870f0; 114     codeobj_main = codeobj_3c4826f777a832afc300183846e870f0;
124     codeobj_35a40ff95ecc1505443ba63870ed0939 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 21, const_tuple_str_plain_gen_str_plain_x_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 115     codeobj_35a40ff95ecc1505443ba63870ed0939 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 21, const_tuple_str_plain_gen_str_plain_x_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
125 } 116 }
126 117
127 // The module function declarations. 118 // The module function declarations.
n 128 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void ); n
129  
130  
131 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 119 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
132 120
133 121
134 // The module function definitions. 122 // The module function definitions.
135 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 123 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
140 #endif 128 #endif
141 129
142     // Local variable declarations. 130     // Local variable declarations.
143     PyObject *var_gen = NULL; 131     PyObject *var_gen = NULL;
144     PyObject *var_x = NULL; 132     PyObject *var_x = NULL;
n 145     PyObject *tmp_genexpr_1__$0 = NULL; n
146     struct Nuitka_FrameObject *frame_35a40ff95ecc1505443ba63870ed0939; 133     struct Nuitka_FrameObject *frame_35a40ff95ecc1505443ba63870ed0939;
147     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 134     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
148     PyObject *exception_type = NULL; 135     PyObject *exception_type = NULL;
149     PyObject *exception_value = NULL; 136     PyObject *exception_value = NULL;
150     PyTracebackObject *exception_tb = NULL; 137     PyTracebackObject *exception_tb = NULL;
157     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 144     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
158 145
159     // Actual function code. 146     // Actual function code.
160     { 147     {
161     PyObject *tmp_assign_source_1; 148     PyObject *tmp_assign_source_1;
n 162     { n
163     PyObject *tmp_assign_source_2;
164     PyObject *tmp_iter_arg_1; 149     PyObject *tmp_iter_arg_1;
n 165     tmp_iter_arg_1 = const_xrange_0_3; n 150     tmp_iter_arg_1 = const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
166     tmp_assign_source_2 = MAKE_ITERATOR( tmp_iter_arg_1 ); 151     tmp_assign_source_1 = MAKE_ITERATOR( tmp_iter_arg_1 );
167     assert( !(tmp_assign_source_2 == NULL) ); 152     assert( !(tmp_assign_source_1 == NULL) );
168     assert( tmp_genexpr_1__$0 == NULL );
169     tmp_genexpr_1__$0 = tmp_assign_source_2;
170  
171     }
172     {
173     // Tried code:
174     {
175     tmp_assign_source_1 = __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker();
176  
177     ((struct Nuitka_GeneratorObject *)tmp_assign_source_1)->m_closure[0] = PyCell_NEW0( tmp_genexpr_1__$0 );
178  
179  
180     goto try_return_handler_1;
181     }
182     // tried codes exits in all cases
183     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
184     return NULL;
185     // Return handler code:
186     try_return_handler_1:;
187     {
188     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
189     Py_DECREF( tmp_genexpr_1__$0 );
190     tmp_genexpr_1__$0 = NULL;
191  
192     }
193     {
194     goto outline_result_1;
195     }
196     // End of try:
197     }
198     {
199     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
200     Py_DECREF( tmp_genexpr_1__$0 );
201     tmp_genexpr_1__$0 = NULL;
202  
203     }
204     // Return statement must have exited already.
205     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
206     return NULL;
207     outline_result_1:;
208     assert( var_gen == NULL ); 153     assert( var_gen == NULL );
209     var_gen = tmp_assign_source_1; 154     var_gen = tmp_assign_source_1;
210 155
211     } 156     }
212     { 157     {
220     // Mark the frame object as in use, ref count 1 will be up for reuse. 165     // Mark the frame object as in use, ref count 1 will be up for reuse.
221     assert( Py_REFCNT( frame_35a40ff95ecc1505443ba63870ed0939 ) == 2 ); // Frame stack 166     assert( Py_REFCNT( frame_35a40ff95ecc1505443ba63870ed0939 ) == 2 ); // Frame stack
222 167
223     // Framed code: 168     // Framed code:
224     { 169     {
n 225     PyObject *tmp_assign_source_3; n 170     PyObject *tmp_assign_source_2;
226     PyObject *tmp_value_name_1; 171     PyObject *tmp_value_name_1;
227     CHECK_OBJECT( var_gen ); 172     CHECK_OBJECT( var_gen );
228     tmp_value_name_1 = var_gen; 173     tmp_value_name_1 = var_gen;
n 229     tmp_assign_source_3 = ITERATOR_NEXT( tmp_value_name_1 ); n 174     tmp_assign_source_2 = ITERATOR_NEXT( tmp_value_name_1 );
230     if ( tmp_assign_source_3 == NULL ) 175     if ( tmp_assign_source_2 == NULL )
231     { 176     {
232         if ( !ERROR_OCCURRED() ) 177         if ( !ERROR_OCCURRED() )
233         { 178         {
234             exception_type = PyExc_StopIteration; 179             exception_type = PyExc_StopIteration;
235             Py_INCREF( exception_type ); 180             Py_INCREF( exception_type );
245         type_description_1 = "oo"; 190         type_description_1 = "oo";
246         exception_lineno = 29; 191         exception_lineno = 29;
247         goto frame_exception_exit_1; 192         goto frame_exception_exit_1;
248     } 193     }
249     assert( var_x == NULL ); 194     assert( var_x == NULL );
n 250     var_x = tmp_assign_source_3; n 195     var_x = tmp_assign_source_2;
251 196
252     } 197     }
253     { 198     {
254     PyObject *tmp_value_name_2; 199     PyObject *tmp_value_name_2;
255     PyObject *tmp_next_value_1; 200     PyObject *tmp_next_value_1;
336 281
337     // Put the previous frame back on top. 282     // Put the previous frame back on top.
338     popFrameStack(); 283     popFrameStack();
339 284
340     // Return the error. 285     // Return the error.
n 341     goto try_except_handler_2; n 286     goto try_except_handler_1;
342 287
343     frame_no_exception_1:; 288     frame_no_exception_1:;
344     { 289     {
345     if ( var_x == NULL ) 290     if ( var_x == NULL )
346     { 291     {
352         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 297         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
353         CHAIN_EXCEPTION( exception_value ); 298         CHAIN_EXCEPTION( exception_value );
354 299
355 300
356 301
n 357         goto try_except_handler_2; n 302         goto try_except_handler_1;
358     } 303     }
359 304
360     tmp_return_value = var_x; 305     tmp_return_value = var_x;
361     Py_INCREF( tmp_return_value ); 306     Py_INCREF( tmp_return_value );
n 362     goto try_return_handler_2; n 307     goto try_return_handler_1;
363     } 308     }
364     // tried codes exits in all cases 309     // tried codes exits in all cases
365     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 310     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
366     return NULL; 311     return NULL;
367     // Return handler code: 312     // Return handler code:
n 368     try_return_handler_2:; n 313     try_return_handler_1:;
369     { 314     {
370     Py_XDECREF( var_gen ); 315     Py_XDECREF( var_gen );
371     var_gen = NULL; 316     var_gen = NULL;
372 317
373     } 318     }
378     } 323     }
379     { 324     {
380     goto function_return_exit; 325     goto function_return_exit;
381     } 326     }
382     // Exception handler code: 327     // Exception handler code:
n 383     try_except_handler_2:; n 328     try_except_handler_1:;
384     exception_keeper_type_1 = exception_type; 329     exception_keeper_type_1 = exception_type;
385     exception_keeper_value_1 = exception_value; 330     exception_keeper_value_1 = exception_value;
386     exception_keeper_tb_1 = exception_tb; 331     exception_keeper_tb_1 = exception_tb;
387     exception_keeper_lineno_1 = exception_lineno; 332     exception_keeper_lineno_1 = exception_lineno;
388     exception_type = NULL; 333     exception_type = NULL;
425 370
426 CHECK_OBJECT( tmp_return_value ); 371 CHECK_OBJECT( tmp_return_value );
427 assert( had_error || !ERROR_OCCURRED() ); 372 assert( had_error || !ERROR_OCCURRED() );
428 return tmp_return_value; 373 return tmp_return_value;
429 374
t 430 } t
431  
432  
433  
434 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
435     PyObject *var_x;
436     PyObject *tmp_iter_value_0;
437     char const *type_description_1;
438     PyObject *exception_type;
439     PyObject *exception_value;
440     PyTracebackObject *exception_tb;
441     int exception_lineno;
442     PyObject *exception_keeper_type_1;
443     PyObject *exception_keeper_value_1;
444     PyTracebackObject *exception_keeper_tb_1;
445     int exception_keeper_lineno_1;
446     PyObject *exception_keeper_type_2;
447     PyObject *exception_keeper_value_2;
448     PyTracebackObject *exception_keeper_tb_2;
449     int exception_keeper_lineno_2;
450 };
451  
452 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
453 {
454     CHECK_OBJECT( (PyObject *)generator );
455     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
456  
457     // Heap access if used.
458     struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *generator_heap = (struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *)generator->m_heap_storage;
459  
460     // Dispatch to yield based on return label index:
461     switch(generator->m_yield_return_index) {
462     case 1: goto yield_return_1;
463     }
464  
465     // Local variable initialization
466     static struct Nuitka_FrameObject *cache_m_frame = NULL;
467     generator_heap->var_x = NULL;
468     generator_heap->tmp_iter_value_0 = NULL;
469     generator_heap->type_description_1 = NULL;
470     generator_heap->exception_type = NULL;
471     generator_heap->exception_value = NULL;
472     generator_heap->exception_tb = NULL;
473     generator_heap->exception_lineno = 0;
474  
475     // Actual function code.
476     {
477     // Tried code:
478     MAKE_OR_REUSE_FRAME( cache_m_frame, codeobj_5f736bdec5dac2f9cd911385793d0797, module___main__, sizeof(void *)+sizeof(void *) );
479     generator->m_frame = cache_m_frame;
480  
481     // Mark the frame object as in use, ref count 1 will be up for reuse.
482     Py_INCREF( generator->m_frame );
483     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
484  
485 #if PYTHON_VERSION >= 340
486     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
487 #endif
488  
489     Py_CLEAR( generator->m_frame->m_frame.f_back );
490  
491     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
492     Py_INCREF( generator->m_frame->m_frame.f_back );
493  
494     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
495     Py_INCREF( generator->m_frame );
496  
497     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
498  
499 #if PYTHON_VERSION >= 300
500     // Accept currently existing exception as the one to publish again when we
501     // yield or yield from.
502     {
503         PyThreadState *thread_state = PyThreadState_GET();
504  
505 #if PYTHON_VERSION < 370
506         generator->m_frame->m_frame.f_exc_type = EXC_TYPE( thread_state );
507     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
508         Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
509     generator->m_frame->m_frame.f_exc_value = EXC_VALUE( thread_state );
510         Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
511     generator->m_frame->m_frame.f_exc_traceback = EXC_TRACEBACK( thread_state );
512         Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
513 #else
514         generator->m_exc_state.exc_type = EXC_TYPE( thread_state );
515         if ( generator->m_exc_state.exc_type == Py_None ) generator->m_exc_state.exc_type = NULL;
516         Py_XINCREF( generator->m_exc_state.exc_type );
517         generator->m_exc_state.exc_value = EXC_VALUE( thread_state );
518         Py_XINCREF( generator->m_exc_state.exc_value );
519         generator->m_exc_state.exc_traceback = EXC_TRACEBACK( thread_state );
520         Py_XINCREF( generator->m_exc_state.exc_traceback );
521 #endif
522     }
523  
524 #endif
525  
526     // Framed code:
527     {
528     // Tried code:
529     {
530     loop_start_1:;
531     {
532     PyObject *tmp_next_source_1;
533     PyObject *tmp_assign_source_1;
534     CHECK_OBJECT( PyCell_GET( generator->m_closure[0] ) );
535     tmp_next_source_1 = PyCell_GET( generator->m_closure[0] );
536     tmp_assign_source_1 = ITERATOR_NEXT( tmp_next_source_1 );
537     if ( tmp_assign_source_1 == NULL )
538     {
539         if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
540         {
541  
542             goto loop_end_1;
543         }
544         else
545         {
546  
547             FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
548             generator_heap->type_description_1 = "No";
549             generator_heap->exception_lineno = 24;
550             goto try_except_handler_2;
551         }
552     }
553  
554     {
555         PyObject *old = generator_heap->tmp_iter_value_0;
556         generator_heap->tmp_iter_value_0 = tmp_assign_source_1;
557         Py_XDECREF( old );
558     }
559  
560     }
561     {
562     PyObject *tmp_assign_source_2;
563     CHECK_OBJECT( generator_heap->tmp_iter_value_0 );
564     tmp_assign_source_2 = generator_heap->tmp_iter_value_0;
565     {
566         PyObject *old = generator_heap->var_x;
567         generator_heap->var_x = tmp_assign_source_2;
568         Py_INCREF( generator_heap->var_x );
569         Py_XDECREF( old );
570     }
571  
572     }
573     {
574     PyObject *tmp_expression_name_1;
575     NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
576     CHECK_OBJECT( generator_heap->var_x );
577     tmp_expression_name_1 = generator_heap->var_x;
578     Py_INCREF( tmp_expression_name_1 );
579     generator->m_yield_return_index = 1;
580     return tmp_expression_name_1;
581     yield_return_1:
582     if ( yield_return_value == NULL )
583     {
584         assert( ERROR_OCCURRED() );
585  
586         FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
587  
588  
589         generator_heap->exception_lineno = 24;
590         generator_heap->type_description_1 = "No";
591         goto try_except_handler_2;
592     }
593     tmp_yield_result_1 = yield_return_value;
594     }
595     if ( CONSIDER_THREADING() == false )
596     {
597         assert( ERROR_OCCURRED() );
598  
599         FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
600  
601  
602         generator_heap->exception_lineno = 24;
603         generator_heap->type_description_1 = "No";
604         goto try_except_handler_2;
605     }
606     goto loop_start_1;
607     loop_end_1:;
608     }
609     goto try_end_1;
610     // Exception handler code:
611     try_except_handler_2:;
612     generator_heap->exception_keeper_type_1 = generator_heap->exception_type;
613     generator_heap->exception_keeper_value_1 = generator_heap->exception_value;
614     generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb;
615     generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno;
616     generator_heap->exception_type = NULL;
617     generator_heap->exception_value = NULL;
618     generator_heap->exception_tb = NULL;
619     generator_heap->exception_lineno = 0;
620  
621     {
622     Py_XDECREF( generator_heap->tmp_iter_value_0 );
623     generator_heap->tmp_iter_value_0 = NULL;
624  
625     }
626     {
627     // Re-raise.
628     generator_heap->exception_type = generator_heap->exception_keeper_type_1;
629     generator_heap->exception_value = generator_heap->exception_keeper_value_1;
630     generator_heap->exception_tb = generator_heap->exception_keeper_tb_1;
631     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1;
632  
633     goto frame_exception_exit_1;
634     }
635     // End of try:
636     try_end_1:;
637     }
638  
639     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
640  
641 #if PYTHON_VERSION >= 370
642     Py_CLEAR( generator->m_exc_state.exc_type );
643     Py_CLEAR( generator->m_exc_state.exc_value );
644     Py_CLEAR( generator->m_exc_state.exc_traceback );
645 #elif PYTHON_VERSION >= 300
646     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
647     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
648     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
649 #endif
650  
651     // Allow re-use of the frame again.
652     Py_DECREF( generator->m_frame );
653     goto frame_no_exception_1;
654  
655     frame_exception_exit_1:;
656  
657     // If it's not an exit exception, consider and create a traceback for it.
658     if ( !EXCEPTION_MATCH_GENERATOR( generator_heap->exception_type ) )
659     {
660         if ( generator_heap->exception_tb == NULL )
661         {
662             generator_heap->exception_tb = MAKE_TRACEBACK( generator->m_frame, generator_heap->exception_lineno );
663         }
664         else if ( generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame )
665         {
666             generator_heap->exception_tb = ADD_TRACEBACK( generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno );
667         }
668  
669         Nuitka_Frame_AttachLocals(
670             (struct Nuitka_FrameObject *)generator->m_frame,
671             generator_heap->type_description_1,
672             NULL,
673             generator_heap->var_x
674         );
675  
676  
677         // Release cached frame.
678         if ( generator->m_frame == cache_m_frame )
679         {
680             Py_DECREF( generator->m_frame );
681         }
682         cache_m_frame = NULL;
683  
684         assertFrameObject( generator->m_frame );
685     }
686  
687 #if PYTHON_VERSION >= 370
688     Py_CLEAR( generator->m_exc_state.exc_type );
689     Py_CLEAR( generator->m_exc_state.exc_value );
690     Py_CLEAR( generator->m_exc_state.exc_traceback );
691 #elif PYTHON_VERSION >= 300
692     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
693     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
694     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
695 #endif
696  
697     Py_DECREF( generator->m_frame );
698  
699     // Return the error.
700     goto try_except_handler_1;
701  
702     frame_no_exception_1:;
703     goto try_end_2;
704     // Exception handler code:
705     try_except_handler_1:;
706     generator_heap->exception_keeper_type_2 = generator_heap->exception_type;
707     generator_heap->exception_keeper_value_2 = generator_heap->exception_value;
708     generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb;
709     generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno;
710     generator_heap->exception_type = NULL;
711     generator_heap->exception_value = NULL;
712     generator_heap->exception_tb = NULL;
713     generator_heap->exception_lineno = 0;
714  
715     {
716     Py_XDECREF( generator_heap->var_x );
717     generator_heap->var_x = NULL;
718  
719     }
720     {
721     // Re-raise.
722     generator_heap->exception_type = generator_heap->exception_keeper_type_2;
723     generator_heap->exception_value = generator_heap->exception_keeper_value_2;
724     generator_heap->exception_tb = generator_heap->exception_keeper_tb_2;
725     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_2;
726  
727     goto function_exception_exit;
728     }
729     // End of try:
730     try_end_2:;
731     }
732     {
733     Py_XDECREF( generator_heap->tmp_iter_value_0 );
734     generator_heap->tmp_iter_value_0 = NULL;
735  
736     }
737     {
738     Py_XDECREF( generator_heap->var_x );
739     generator_heap->var_x = NULL;
740  
741     }
742  
743  
744     return NULL;
745  
746     function_exception_exit:
747     assert( generator_heap->exception_type );
748     RESTORE_ERROR_OCCURRED( generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb );
749  
750     return NULL;
751  
752 }
753  
754 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void )
755 {
756     return Nuitka_Generator_New(
757         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
758         module___main__,
759         const_str_angle_genexpr,
760 #if PYTHON_VERSION >= 350
761         const_str_digest_57aac74124c55d29a6f122835861daff,
762 #endif
763         codeobj_5f736bdec5dac2f9cd911385793d0797,
764         1,
765         sizeof(struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals)
766     );
767 } 375 }
768 376
769 377
770 378
771 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 379 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )