Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)23540249888.11538461538461257.0CPython 2.745179853240.03846153846155456.6875244787367Nuitka (master)45180490391.96153846153845456.68685578362374Nuitka (develop)45180302543.8846153846154456.6870531379114Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23509232188.11538461538461257.0CPython 3.558079922240.03846153846155443.06514612860076Nuitka (master)58073517391.96153846153845443.0718786923516Nuitka (develop)58075971543.8846153846154443.0692991901745Nuitka (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;
n 56 static PyObject *const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple; n 51 static PyObject *const_int_pos_2;
57 static PyObject *const_tuple_none_int_pos_50000_tuple; 52 static PyObject *const_tuple_none_int_pos_50000_tuple;
58 extern PyObject *const_str_plain___main__; 53 extern PyObject *const_str_plain___main__;
n n 54 static PyObject *const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
59 extern PyObject *const_str_plain___doc__; 55 extern PyObject *const_str_plain___doc__;
60 extern PyObject *const_str_plain___cached__; 56 extern PyObject *const_str_plain___cached__;
61 static PyObject *const_str_plain___debug__; 57 static PyObject *const_str_plain___debug__;
62 static PyObject *const_str_digest_2d98434abe021242cf9aa194107c5a51; 58 static PyObject *const_str_digest_2d98434abe021242cf9aa194107c5a51;
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_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple = PyTuple_New( 2 ); 80     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul );
90     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 0, const_str_digest_b9c4baf879ebd882d40843df3a4dead7 ); Py_INCREF( const_str_digest_b9c4baf879ebd882d40843df3a4dead7 );
91     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
92     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 81     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
93     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 82     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
94     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 83     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n n 84     const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple = PyTuple_New( 3 );
85     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 );
86     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 );
87     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 );
95     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 72 ], 9, 1 ); 88     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 50 ], 9, 1 );
96     const_str_digest_2d98434abe021242cf9aa194107c5a51 = UNSTREAM_STRING_ASCII( &constant_bin[ 81 ], 78, 0 ); 89     const_str_digest_2d98434abe021242cf9aa194107c5a51 = UNSTREAM_STRING_ASCII( &constant_bin[ 59 ], 78, 0 );
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_a376a81d7b13ea21e609182335e1cf76; n
113 static PyCodeObject *codeobj_de89a345d2e3adfe7cf971a2d6f3a19a; 105 static PyCodeObject *codeobj_de89a345d2e3adfe7cf971a2d6f3a19a;
114 static PyCodeObject *codeobj_3add1ed449e13102ef854034223f3c9b; 106 static PyCodeObject *codeobj_3add1ed449e13102ef854034223f3c9b;
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_2d98434abe021242cf9aa194107c5a51; 112     module_filename_obj = const_str_digest_2d98434abe021242cf9aa194107c5a51;
n 121     codeobj_a376a81d7b13ea21e609182335e1cf76 = 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_de89a345d2e3adfe7cf971a2d6f3a19a = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 113     codeobj_de89a345d2e3adfe7cf971a2d6f3a19a = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
123     codeobj_main = codeobj_de89a345d2e3adfe7cf971a2d6f3a19a; 114     codeobj_main = codeobj_de89a345d2e3adfe7cf971a2d6f3a19a;
124     codeobj_3add1ed449e13102ef854034223f3c9b = 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_3add1ed449e13102ef854034223f3c9b = 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_3add1ed449e13102ef854034223f3c9b; 133     struct Nuitka_FrameObject *frame_3add1ed449e13102ef854034223f3c9b;
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_3add1ed449e13102ef854034223f3c9b ) == 2 ); // Frame stack 166     assert( Py_REFCNT( frame_3add1ed449e13102ef854034223f3c9b ) == 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;
322 267
323     // Put the previous frame back on top. 268     // Put the previous frame back on top.
324     popFrameStack(); 269     popFrameStack();
325 270
326     // Return the error. 271     // Return the error.
n 327     goto try_except_handler_2; n 272     goto try_except_handler_1;
328 273
329     frame_no_exception_1:; 274     frame_no_exception_1:;
330     { 275     {
331     CHECK_OBJECT( var_x ); 276     CHECK_OBJECT( var_x );
332     tmp_return_value = var_x; 277     tmp_return_value = var_x;
333     Py_INCREF( tmp_return_value ); 278     Py_INCREF( tmp_return_value );
n 334     goto try_return_handler_2; n 279     goto try_return_handler_1;
335     } 280     }
336     // tried codes exits in all cases 281     // tried codes exits in all cases
337     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 282     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
338     return NULL; 283     return NULL;
339     // Return handler code: 284     // Return handler code:
n 340     try_return_handler_2:; n 285     try_return_handler_1:;
341     { 286     {
342     CHECK_OBJECT( (PyObject *)var_gen ); 287     CHECK_OBJECT( (PyObject *)var_gen );
343     Py_DECREF( var_gen ); 288     Py_DECREF( var_gen );
344     var_gen = NULL; 289     var_gen = NULL;
345 290
352     } 297     }
353     { 298     {
354     goto function_return_exit; 299     goto function_return_exit;
355     } 300     }
356     // Exception handler code: 301     // Exception handler code:
n 357     try_except_handler_2:; n 302     try_except_handler_1:;
358     exception_keeper_type_1 = exception_type; 303     exception_keeper_type_1 = exception_type;
359     exception_keeper_value_1 = exception_value; 304     exception_keeper_value_1 = exception_value;
360     exception_keeper_tb_1 = exception_tb; 305     exception_keeper_tb_1 = exception_tb;
361     exception_keeper_lineno_1 = exception_lineno; 306     exception_keeper_lineno_1 = exception_lineno;
362     exception_type = NULL; 307     exception_type = NULL;
400 345
401 CHECK_OBJECT( tmp_return_value ); 346 CHECK_OBJECT( tmp_return_value );
402 assert( had_error || !ERROR_OCCURRED() ); 347 assert( had_error || !ERROR_OCCURRED() );
403 return tmp_return_value; 348 return tmp_return_value;
404 349
t 405 } t
406  
407  
408  
409 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
410     PyObject *var_x;
411     PyObject *tmp_iter_value_0;
412     char const *type_description_1;
413     PyObject *exception_type;
414     PyObject *exception_value;
415     PyTracebackObject *exception_tb;
416     int exception_lineno;
417     PyObject *exception_keeper_type_1;
418     PyObject *exception_keeper_value_1;
419     PyTracebackObject *exception_keeper_tb_1;
420     int exception_keeper_lineno_1;
421     PyObject *exception_keeper_type_2;
422     PyObject *exception_keeper_value_2;
423     PyTracebackObject *exception_keeper_tb_2;
424     int exception_keeper_lineno_2;
425 };
426  
427 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
428 {
429     CHECK_OBJECT( (PyObject *)generator );
430     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
431  
432     // Heap access if used.
433     struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *generator_heap = (struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *)generator->m_heap_storage;
434  
435     // Dispatch to yield based on return label index:
436     switch(generator->m_yield_return_index) {
437     case 1: goto yield_return_1;
438     }
439  
440     // Local variable initialization
441     static struct Nuitka_FrameObject *cache_m_frame = NULL;
442     generator_heap->var_x = NULL;
443     generator_heap->tmp_iter_value_0 = NULL;
444     generator_heap->type_description_1 = NULL;
445     generator_heap->exception_type = NULL;
446     generator_heap->exception_value = NULL;
447     generator_heap->exception_tb = NULL;
448     generator_heap->exception_lineno = 0;
449  
450     // Actual function code.
451     {
452     // Tried code:
453     MAKE_OR_REUSE_FRAME( cache_m_frame, codeobj_a376a81d7b13ea21e609182335e1cf76, module___main__, sizeof(void *)+sizeof(void *) );
454     generator->m_frame = cache_m_frame;
455  
456     // Mark the frame object as in use, ref count 1 will be up for reuse.
457     Py_INCREF( generator->m_frame );
458     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
459  
460 #if PYTHON_VERSION >= 340
461     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
462 #endif
463  
464     Py_CLEAR( generator->m_frame->m_frame.f_back );
465  
466     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
467     Py_INCREF( generator->m_frame->m_frame.f_back );
468  
469     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
470     Py_INCREF( generator->m_frame );
471  
472     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
473  
474 #if PYTHON_VERSION >= 300
475     // Accept currently existing exception as the one to publish again when we
476     // yield or yield from.
477     {
478         PyThreadState *thread_state = PyThreadState_GET();
479  
480 #if PYTHON_VERSION < 370
481         generator->m_frame->m_frame.f_exc_type = EXC_TYPE( thread_state );
482     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
483         Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
484     generator->m_frame->m_frame.f_exc_value = EXC_VALUE( thread_state );
485         Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
486     generator->m_frame->m_frame.f_exc_traceback = EXC_TRACEBACK( thread_state );
487         Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
488 #else
489         generator->m_exc_state.exc_type = EXC_TYPE( thread_state );
490         if ( generator->m_exc_state.exc_type == Py_None ) generator->m_exc_state.exc_type = NULL;
491         Py_XINCREF( generator->m_exc_state.exc_type );
492         generator->m_exc_state.exc_value = EXC_VALUE( thread_state );
493         Py_XINCREF( generator->m_exc_state.exc_value );
494         generator->m_exc_state.exc_traceback = EXC_TRACEBACK( thread_state );
495         Py_XINCREF( generator->m_exc_state.exc_traceback );
496 #endif
497     }
498  
499 #endif
500  
501     // Framed code:
502     {
503     // Tried code:
504     {
505     loop_start_1:;
506     {
507     PyObject *tmp_next_source_1;
508     PyObject *tmp_assign_source_1;
509     CHECK_OBJECT( PyCell_GET( generator->m_closure[0] ) );
510     tmp_next_source_1 = PyCell_GET( generator->m_closure[0] );
511     tmp_assign_source_1 = ITERATOR_NEXT( tmp_next_source_1 );
512     if ( tmp_assign_source_1 == NULL )
513     {
514         if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
515         {
516  
517             goto loop_end_1;
518         }
519         else
520         {
521  
522             FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
523             generator_heap->type_description_1 = "No";
524             generator_heap->exception_lineno = 24;
525             goto try_except_handler_2;
526         }
527     }
528  
529     {
530         PyObject *old = generator_heap->tmp_iter_value_0;
531         generator_heap->tmp_iter_value_0 = tmp_assign_source_1;
532         Py_XDECREF( old );
533     }
534  
535     }
536     {
537     PyObject *tmp_assign_source_2;
538     CHECK_OBJECT( generator_heap->tmp_iter_value_0 );
539     tmp_assign_source_2 = generator_heap->tmp_iter_value_0;
540     {
541         PyObject *old = generator_heap->var_x;
542         generator_heap->var_x = tmp_assign_source_2;
543         Py_INCREF( generator_heap->var_x );
544         Py_XDECREF( old );
545     }
546  
547     }
548     {
549     PyObject *tmp_expression_name_1;
550     NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
551     CHECK_OBJECT( generator_heap->var_x );
552     tmp_expression_name_1 = generator_heap->var_x;
553     Py_INCREF( tmp_expression_name_1 );
554     generator->m_yield_return_index = 1;
555     return tmp_expression_name_1;
556     yield_return_1:
557     if ( yield_return_value == NULL )
558     {
559         assert( ERROR_OCCURRED() );
560  
561         FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
562  
563  
564         generator_heap->exception_lineno = 24;
565         generator_heap->type_description_1 = "No";
566         goto try_except_handler_2;
567     }
568     tmp_yield_result_1 = yield_return_value;
569     }
570     if ( CONSIDER_THREADING() == false )
571     {
572         assert( ERROR_OCCURRED() );
573  
574         FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
575  
576  
577         generator_heap->exception_lineno = 24;
578         generator_heap->type_description_1 = "No";
579         goto try_except_handler_2;
580     }
581     goto loop_start_1;
582     loop_end_1:;
583     }
584     goto try_end_1;
585     // Exception handler code:
586     try_except_handler_2:;
587     generator_heap->exception_keeper_type_1 = generator_heap->exception_type;
588     generator_heap->exception_keeper_value_1 = generator_heap->exception_value;
589     generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb;
590     generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno;
591     generator_heap->exception_type = NULL;
592     generator_heap->exception_value = NULL;
593     generator_heap->exception_tb = NULL;
594     generator_heap->exception_lineno = 0;
595  
596     {
597     Py_XDECREF( generator_heap->tmp_iter_value_0 );
598     generator_heap->tmp_iter_value_0 = NULL;
599  
600     }
601     {
602     // Re-raise.
603     generator_heap->exception_type = generator_heap->exception_keeper_type_1;
604     generator_heap->exception_value = generator_heap->exception_keeper_value_1;
605     generator_heap->exception_tb = generator_heap->exception_keeper_tb_1;
606     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1;
607  
608     goto frame_exception_exit_1;
609     }
610     // End of try:
611     try_end_1:;
612     }
613  
614     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
615  
616 #if PYTHON_VERSION >= 370
617     Py_CLEAR( generator->m_exc_state.exc_type );
618     Py_CLEAR( generator->m_exc_state.exc_value );
619     Py_CLEAR( generator->m_exc_state.exc_traceback );
620 #elif PYTHON_VERSION >= 300
621     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
622     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
623     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
624 #endif
625  
626     // Allow re-use of the frame again.
627     Py_DECREF( generator->m_frame );
628     goto frame_no_exception_1;
629  
630     frame_exception_exit_1:;
631  
632     // If it's not an exit exception, consider and create a traceback for it.
633     if ( !EXCEPTION_MATCH_GENERATOR( generator_heap->exception_type ) )
634     {
635         if ( generator_heap->exception_tb == NULL )
636         {
637             generator_heap->exception_tb = MAKE_TRACEBACK( generator->m_frame, generator_heap->exception_lineno );
638         }
639         else if ( generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame )
640         {
641             generator_heap->exception_tb = ADD_TRACEBACK( generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno );
642         }
643  
644         Nuitka_Frame_AttachLocals(
645             (struct Nuitka_FrameObject *)generator->m_frame,
646             generator_heap->type_description_1,
647             NULL,
648             generator_heap->var_x
649         );
650  
651  
652         // Release cached frame.
653         if ( generator->m_frame == cache_m_frame )
654         {
655             Py_DECREF( generator->m_frame );
656         }
657         cache_m_frame = NULL;
658  
659         assertFrameObject( generator->m_frame );
660     }
661  
662 #if PYTHON_VERSION >= 370
663     Py_CLEAR( generator->m_exc_state.exc_type );
664     Py_CLEAR( generator->m_exc_state.exc_value );
665     Py_CLEAR( generator->m_exc_state.exc_traceback );
666 #elif PYTHON_VERSION >= 300
667     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
668     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
669     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
670 #endif
671  
672     Py_DECREF( generator->m_frame );
673  
674     // Return the error.
675     goto try_except_handler_1;
676  
677     frame_no_exception_1:;
678     goto try_end_2;
679     // Exception handler code:
680     try_except_handler_1:;
681     generator_heap->exception_keeper_type_2 = generator_heap->exception_type;
682     generator_heap->exception_keeper_value_2 = generator_heap->exception_value;
683     generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb;
684     generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno;
685     generator_heap->exception_type = NULL;
686     generator_heap->exception_value = NULL;
687     generator_heap->exception_tb = NULL;
688     generator_heap->exception_lineno = 0;
689  
690     {
691     Py_XDECREF( generator_heap->var_x );
692     generator_heap->var_x = NULL;
693  
694     }
695     {
696     // Re-raise.
697     generator_heap->exception_type = generator_heap->exception_keeper_type_2;
698     generator_heap->exception_value = generator_heap->exception_keeper_value_2;
699     generator_heap->exception_tb = generator_heap->exception_keeper_tb_2;
700     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_2;
701  
702     goto function_exception_exit;
703     }
704     // End of try:
705     try_end_2:;
706     }
707     {
708     Py_XDECREF( generator_heap->tmp_iter_value_0 );
709     generator_heap->tmp_iter_value_0 = NULL;
710  
711     }
712     {
713     Py_XDECREF( generator_heap->var_x );
714     generator_heap->var_x = NULL;
715  
716     }
717  
718  
719     return NULL;
720  
721     function_exception_exit:
722     assert( generator_heap->exception_type );
723     RESTORE_ERROR_OCCURRED( generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb );
724  
725     return NULL;
726  
727 }
728  
729 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void )
730 {
731     return Nuitka_Generator_New(
732         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
733         module___main__,
734         const_str_angle_genexpr,
735 #if PYTHON_VERSION >= 350
736         const_str_digest_57aac74124c55d29a6f122835861daff,
737 #endif
738         codeobj_a376a81d7b13ea21e609182335e1cf76,
739         1,
740         sizeof(struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals)
741     );
742 } 350 }
743 351
744 352
745 353
746 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 354 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )