Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)23395291088.11538461538461257.0CPython 2.745179696240.03846153846155456.3938240934567Nuitka (master)45180398391.96153846153845456.39308259808485Nuitka (develop)45180506543.8846153846154456.3929685218738Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23604430888.11538461538461257.0CPython 3.558076121240.03846153846155443.3153462688357Nuitka (master)58076151391.96153846153845443.3153148617596Nuitka (develop)58076168543.8846153846154443.3152970644165Nuitka (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 declarations of module constants used, if any. */ 33 /* The declarations of 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 static PyObject *const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046; 53 static PyObject *const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046;
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
66 static bool constants_created = false; 62 static bool constants_created = false;
67 63
68 /* Function to create module private constants. */ 64 /* Function to create module private constants. */
69 static void createModuleConstants( void ) 65 static void createModuleConstants( void )
70 { 66 {
n 71     const_str_digest_57aac74124c55d29a6f122835861daff = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 35, 0 ); n
72     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 35 ], 9, 1 ); 67     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 );
68     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
73     const_str_plain_False = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 5, 1 ); 69     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 3, 1 );
74     const_str_angle_genexpr = UNSTREAM_STRING_ASCII( &constant_bin[ 26 ], 9, 0 );
75     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul ); 70     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul );
n 76     const_xrange_0_3 = BUILTIN_XRANGE3( const_int_0, const_int_pos_3, const_int_pos_1 ); n
77     const_str_digest_b9c4baf879ebd882d40843df3a4dead7 = UNSTREAM_STRING_ASCII( &constant_bin[ 49 ], 2, 1 );
78     const_str_plain_gen = UNSTREAM_STRING_ASCII( &constant_bin[ 27 ], 3, 1 );
79     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
80     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 71     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 81     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 51 ], 3, 0 ); n 72     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 12 ], 3, 0 );
82     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 73     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 83     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 16, 1 ); n 74     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 15 ], 16, 1 );
84     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 54 ], 8, 0 ); 75     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 8, 0 );
85     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 62 ], 4, 1 ); 76     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 39 ], 4, 1 );
86     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 1, 1 ); 77     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 43 ], 1, 1 );
87     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 ); 78     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 );
88     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen ); 79     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen );
89     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 80     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
n 90     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 66 ], 6, 1 ); n 81     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 6, 1 );
91     const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple = PyTuple_New( 2 ); 82     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul );
92     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 0, const_str_digest_b9c4baf879ebd882d40843df3a4dead7 ); Py_INCREF( const_str_digest_b9c4baf879ebd882d40843df3a4dead7 );
93     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
94     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 83     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
95     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 84     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
96     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 85     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 97     const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046 = UNSTREAM_STRING_ASCII( &constant_bin[ 72 ], 78, 0 ); n 86     const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046 = UNSTREAM_STRING_ASCII( &constant_bin[ 50 ], 78, 0 );
87     const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple = PyTuple_New( 3 );
88     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 );
89     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 );
90     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 );
98     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 150 ], 9, 1 ); 91     const_str_plain___debug__ = UNSTREAM_STRING_ASCII( &constant_bin[ 128 ], 9, 1 );
99 92
100     constants_created = true; 93     constants_created = true;
101 } 94 }
102 95
103 /* Function to verify module private constants for non-corruption. */ 96 /* Function to verify module private constants for non-corruption. */
110 103
111 } 104 }
112 #endif 105 #endif
113 106
114 // The module code objects. 107 // The module code objects.
n 115 static PyCodeObject *codeobj_ad26b251ad716ea9c4da7b5ac89fe7b6; n
116 static PyCodeObject *codeobj_4d855064f4afff5ab6b5dc0ae13e98c1; 108 static PyCodeObject *codeobj_4d855064f4afff5ab6b5dc0ae13e98c1;
117 static PyCodeObject *codeobj_f6d25c0341f03dede8edf5bc387b5fbb; 109 static PyCodeObject *codeobj_f6d25c0341f03dede8edf5bc387b5fbb;
118 /* For use in "MainProgram.c". */ 110 /* For use in "MainProgram.c". */
119 PyCodeObject *codeobj_main = NULL; 111 PyCodeObject *codeobj_main = NULL;
120 112
121 static void createModuleCodeObjects(void) 113 static void createModuleCodeObjects(void)
122 { 114 {
123     module_filename_obj = const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046; 115     module_filename_obj = const_str_digest_3cb79e6b92c70b9e66ad8fc20d3f9046;
n 124     codeobj_ad26b251ad716ea9c4da7b5ac89fe7b6 = 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
125     codeobj_4d855064f4afff5ab6b5dc0ae13e98c1 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 116     codeobj_4d855064f4afff5ab6b5dc0ae13e98c1 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
126     codeobj_main = codeobj_4d855064f4afff5ab6b5dc0ae13e98c1; 117     codeobj_main = codeobj_4d855064f4afff5ab6b5dc0ae13e98c1;
127     codeobj_f6d25c0341f03dede8edf5bc387b5fbb = 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 ); 118     codeobj_f6d25c0341f03dede8edf5bc387b5fbb = 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 );
128 } 119 }
129 120
130 // The module function declarations. 121 // The module function declarations.
n 131 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void ); n
132  
133  
134 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 122 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
135 123
136 124
137 // The module function definitions. 125 // The module function definitions.
138 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 126 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
143 #endif 131 #endif
144 132
145     // Local variable declarations. 133     // Local variable declarations.
146     PyObject *var_gen = NULL; 134     PyObject *var_gen = NULL;
147     PyObject *var_x = NULL; 135     PyObject *var_x = NULL;
n 148     PyObject *tmp_genexpr_1__$0 = NULL; n
149     struct Nuitka_FrameObject *frame_f6d25c0341f03dede8edf5bc387b5fbb; 136     struct Nuitka_FrameObject *frame_f6d25c0341f03dede8edf5bc387b5fbb;
150     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 137     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
151     PyObject *exception_type = NULL; 138     PyObject *exception_type = NULL;
152     PyObject *exception_value = NULL; 139     PyObject *exception_value = NULL;
153     PyTracebackObject *exception_tb = NULL; 140     PyTracebackObject *exception_tb = NULL;
160     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 147     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
161 148
162     // Actual function body. 149     // Actual function body.
163     { 150     {
164         PyObject *tmp_assign_source_1; 151         PyObject *tmp_assign_source_1;
n 165         { n
166             PyObject *tmp_assign_source_2;
167             PyObject *tmp_iter_arg_1; 152         PyObject *tmp_iter_arg_1;
168             tmp_iter_arg_1 = const_xrange_0_3; 153         tmp_iter_arg_1 = const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
169             tmp_assign_source_2 = MAKE_ITERATOR( tmp_iter_arg_1 ); 154         tmp_assign_source_1 = MAKE_ITERATOR( tmp_iter_arg_1 );
170             assert( !(tmp_assign_source_2 == NULL) ); 155         assert( !(tmp_assign_source_1 == NULL) );
171             assert( tmp_genexpr_1__$0 == NULL );
172             tmp_genexpr_1__$0 = tmp_assign_source_2;
173         }
174         // Tried code:
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         // tried codes exits in all cases
182         NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
183         return NULL;
184         // Return handler code:
185         try_return_handler_1:;
186         CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
187         Py_DECREF( tmp_genexpr_1__$0 );
188         tmp_genexpr_1__$0 = NULL;
189  
190         goto outline_result_1;
191         // End of try:
192         CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
193         Py_DECREF( tmp_genexpr_1__$0 );
194         tmp_genexpr_1__$0 = NULL;
195  
196         // Return statement must have exited already.
197         NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
198         return NULL;
199         outline_result_1:;
200         assert( var_gen == NULL ); 156         assert( var_gen == NULL );
201         var_gen = tmp_assign_source_1; 157         var_gen = tmp_assign_source_1;
202     } 158     }
203     // Tried code: 159     // Tried code:
204     MAKE_OR_REUSE_FRAME( cache_frame_f6d25c0341f03dede8edf5bc387b5fbb, codeobj_f6d25c0341f03dede8edf5bc387b5fbb, module___main__, sizeof(void *)+sizeof(void *) ); 160     MAKE_OR_REUSE_FRAME( cache_frame_f6d25c0341f03dede8edf5bc387b5fbb, codeobj_f6d25c0341f03dede8edf5bc387b5fbb, module___main__, sizeof(void *)+sizeof(void *) );
210     // Mark the frame object as in use, ref count 1 will be up for reuse. 166     // Mark the frame object as in use, ref count 1 will be up for reuse.
211     assert( Py_REFCNT( frame_f6d25c0341f03dede8edf5bc387b5fbb ) == 2 ); // Frame stack 167     assert( Py_REFCNT( frame_f6d25c0341f03dede8edf5bc387b5fbb ) == 2 ); // Frame stack
212 168
213     // Framed code: 169     // Framed code:
214     { 170     {
n 215         PyObject *tmp_assign_source_3; n 171         PyObject *tmp_assign_source_2;
216         PyObject *tmp_value_name_1; 172         PyObject *tmp_value_name_1;
217         CHECK_OBJECT( var_gen ); 173         CHECK_OBJECT( var_gen );
218         tmp_value_name_1 = var_gen; 174         tmp_value_name_1 = var_gen;
n 219         tmp_assign_source_3 = ITERATOR_NEXT( tmp_value_name_1 ); n 175         tmp_assign_source_2 = ITERATOR_NEXT( tmp_value_name_1 );
220         if ( tmp_assign_source_3 == NULL ) 176         if ( tmp_assign_source_2 == NULL )
221         { 177         {
222             if ( !ERROR_OCCURRED() ) 178             if ( !ERROR_OCCURRED() )
223             { 179             {
224                 exception_type = PyExc_StopIteration; 180                 exception_type = PyExc_StopIteration;
225                 Py_INCREF( exception_type ); 181                 Py_INCREF( exception_type );
235             type_description_1 = "oo"; 191             type_description_1 = "oo";
236             exception_lineno = 29; 192             exception_lineno = 29;
237             goto frame_exception_exit_1; 193             goto frame_exception_exit_1;
238         } 194         }
239         assert( var_x == NULL ); 195         assert( var_x == NULL );
n 240         var_x = tmp_assign_source_3; n 196         var_x = tmp_assign_source_2;
241     } 197     }
242     { 198     {
243         PyObject *tmp_value_name_2; 199         PyObject *tmp_value_name_2;
244         PyObject *tmp_next_value_1; 200         PyObject *tmp_next_value_1;
245         CHECK_OBJECT( var_gen ); 201         CHECK_OBJECT( var_gen );
311 267
312     // Put the previous frame back on top. 268     // Put the previous frame back on top.
313     popFrameStack(); 269     popFrameStack();
314 270
315     // Return the error. 271     // Return the error.
n 316     goto try_except_handler_2; n 272     goto try_except_handler_1;
317 273
318     frame_no_exception_1:; 274     frame_no_exception_1:;
319     CHECK_OBJECT( var_x ); 275     CHECK_OBJECT( var_x );
320     tmp_return_value = var_x; 276     tmp_return_value = var_x;
321     Py_INCREF( tmp_return_value ); 277     Py_INCREF( tmp_return_value );
n 322     goto try_return_handler_2; n 278     goto try_return_handler_1;
323     // tried codes exits in all cases 279     // tried codes exits in all cases
324     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 280     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
325     return NULL; 281     return NULL;
326     // Return handler code: 282     // Return handler code:
n 327     try_return_handler_2:; n 283     try_return_handler_1:;
328     CHECK_OBJECT( (PyObject *)var_gen ); 284     CHECK_OBJECT( (PyObject *)var_gen );
329     Py_DECREF( var_gen ); 285     Py_DECREF( var_gen );
330     var_gen = NULL; 286     var_gen = NULL;
331 287
332     CHECK_OBJECT( (PyObject *)var_x ); 288     CHECK_OBJECT( (PyObject *)var_x );
333     Py_DECREF( var_x ); 289     Py_DECREF( var_x );
334     var_x = NULL; 290     var_x = NULL;
335 291
336     goto function_return_exit; 292     goto function_return_exit;
337     // Exception handler code: 293     // Exception handler code:
n 338     try_except_handler_2:; n 294     try_except_handler_1:;
339     exception_keeper_type_1 = exception_type; 295     exception_keeper_type_1 = exception_type;
340     exception_keeper_value_1 = exception_value; 296     exception_keeper_value_1 = exception_value;
341     exception_keeper_tb_1 = exception_tb; 297     exception_keeper_tb_1 = exception_tb;
342     exception_keeper_lineno_1 = exception_lineno; 298     exception_keeper_lineno_1 = exception_lineno;
343     exception_type = NULL; 299     exception_type = NULL;
378    // Actual function exit with return value, making sure we did not make 334    // Actual function exit with return value, making sure we did not make
379    // the error status worse despite non-NULL return. 335    // the error status worse despite non-NULL return.
380    CHECK_OBJECT( tmp_return_value ); 336    CHECK_OBJECT( tmp_return_value );
381    assert( had_error || !ERROR_OCCURRED() ); 337    assert( had_error || !ERROR_OCCURRED() );
382    return tmp_return_value; 338    return tmp_return_value;
t 383 } t
384  
385  
386  
387 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
388     PyObject *var_x;
389     PyObject *tmp_iter_value_0;
390     char const *type_description_1;
391     PyObject *exception_type;
392     PyObject *exception_value;
393     PyTracebackObject *exception_tb;
394     int exception_lineno;
395     PyObject *exception_keeper_type_1;
396     PyObject *exception_keeper_value_1;
397     PyTracebackObject *exception_keeper_tb_1;
398     int exception_keeper_lineno_1;
399     PyObject *exception_keeper_type_2;
400     PyObject *exception_keeper_value_2;
401     PyTracebackObject *exception_keeper_tb_2;
402     int exception_keeper_lineno_2;
403 };
404  
405 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
406 {
407     CHECK_OBJECT( (PyObject *)generator );
408     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
409  
410     // Heap access if used.
411     struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *generator_heap = (struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *)generator->m_heap_storage;
412  
413     // Dispatch to yield based on return label index:
414     switch(generator->m_yield_return_index) {
415     case 1: goto yield_return_1;
416     }
417  
418     // Local variable initialization
419     static struct Nuitka_FrameObject *cache_m_frame = NULL;
420     generator_heap->var_x = NULL;
421     generator_heap->tmp_iter_value_0 = NULL;
422     generator_heap->type_description_1 = NULL;
423     generator_heap->exception_type = NULL;
424     generator_heap->exception_value = NULL;
425     generator_heap->exception_tb = NULL;
426     generator_heap->exception_lineno = 0;
427  
428     // Actual generator function body.
429     // Tried code:
430     MAKE_OR_REUSE_FRAME( cache_m_frame, codeobj_ad26b251ad716ea9c4da7b5ac89fe7b6, module___main__, sizeof(void *)+sizeof(void *) );
431     generator->m_frame = cache_m_frame;
432  
433     // Mark the frame object as in use, ref count 1 will be up for reuse.
434     Py_INCREF( generator->m_frame );
435     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
436  
437 #if PYTHON_VERSION >= 340
438     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
439 #endif
440  
441     Py_CLEAR( generator->m_frame->m_frame.f_back );
442  
443     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
444     Py_INCREF( generator->m_frame->m_frame.f_back );
445  
446     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
447     Py_INCREF( generator->m_frame );
448  
449     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
450  
451 #if PYTHON_VERSION >= 300
452     // Accept currently existing exception as the one to publish again when we
453     // yield or yield from.
454     {
455         PyThreadState *thread_state = PyThreadState_GET();
456  
457 #if PYTHON_VERSION < 370
458         generator->m_frame->m_frame.f_exc_type = EXC_TYPE( thread_state );
459     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
460         Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
461     generator->m_frame->m_frame.f_exc_value = EXC_VALUE( thread_state );
462         Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
463     generator->m_frame->m_frame.f_exc_traceback = EXC_TRACEBACK( thread_state );
464         Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
465 #else
466         generator->m_exc_state.exc_type = EXC_TYPE( thread_state );
467         if ( generator->m_exc_state.exc_type == Py_None ) generator->m_exc_state.exc_type = NULL;
468         Py_XINCREF( generator->m_exc_state.exc_type );
469         generator->m_exc_state.exc_value = EXC_VALUE( thread_state );
470         Py_XINCREF( generator->m_exc_state.exc_value );
471         generator->m_exc_state.exc_traceback = EXC_TRACEBACK( thread_state );
472         Py_XINCREF( generator->m_exc_state.exc_traceback );
473 #endif
474     }
475  
476 #endif
477  
478     // Framed code:
479     // Tried code:
480     loop_start_1:;
481     {
482         PyObject *tmp_next_source_1;
483         PyObject *tmp_assign_source_1;
484         CHECK_OBJECT( PyCell_GET( generator->m_closure[0] ) );
485         tmp_next_source_1 = PyCell_GET( generator->m_closure[0] );
486         tmp_assign_source_1 = ITERATOR_NEXT( tmp_next_source_1 );
487         if ( tmp_assign_source_1 == NULL )
488         {
489             if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
490             {
491  
492                 goto loop_end_1;
493             }
494             else
495             {
496  
497                 FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
498                 generator_heap->type_description_1 = "No";
499                 generator_heap->exception_lineno = 24;
500                 goto try_except_handler_2;
501             }
502         }
503  
504         {
505             PyObject *old = generator_heap->tmp_iter_value_0;
506             generator_heap->tmp_iter_value_0 = tmp_assign_source_1;
507             Py_XDECREF( old );
508         }
509  
510     }
511     {
512         PyObject *tmp_assign_source_2;
513         CHECK_OBJECT( generator_heap->tmp_iter_value_0 );
514         tmp_assign_source_2 = generator_heap->tmp_iter_value_0;
515         {
516             PyObject *old = generator_heap->var_x;
517             generator_heap->var_x = tmp_assign_source_2;
518             Py_INCREF( generator_heap->var_x );
519             Py_XDECREF( old );
520         }
521  
522     }
523     {
524         PyObject *tmp_expression_name_1;
525         NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
526         CHECK_OBJECT( generator_heap->var_x );
527         tmp_expression_name_1 = generator_heap->var_x;
528         Py_INCREF( tmp_expression_name_1 );
529         generator->m_yield_return_index = 1;
530         return tmp_expression_name_1;
531         yield_return_1:
532         if ( yield_return_value == NULL )
533         {
534             assert( ERROR_OCCURRED() );
535  
536             FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
537  
538  
539             generator_heap->exception_lineno = 24;
540             generator_heap->type_description_1 = "No";
541             goto try_except_handler_2;
542         }
543         tmp_yield_result_1 = yield_return_value;
544     }
545     if ( CONSIDER_THREADING() == false )
546     {
547         assert( ERROR_OCCURRED() );
548  
549         FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
550  
551  
552         generator_heap->exception_lineno = 24;
553         generator_heap->type_description_1 = "No";
554         goto try_except_handler_2;
555     }
556     goto loop_start_1;
557     loop_end_1:;
558     goto try_end_1;
559     // Exception handler code:
560     try_except_handler_2:;
561     generator_heap->exception_keeper_type_1 = generator_heap->exception_type;
562     generator_heap->exception_keeper_value_1 = generator_heap->exception_value;
563     generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb;
564     generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno;
565     generator_heap->exception_type = NULL;
566     generator_heap->exception_value = NULL;
567     generator_heap->exception_tb = NULL;
568     generator_heap->exception_lineno = 0;
569  
570     Py_XDECREF( generator_heap->tmp_iter_value_0 );
571     generator_heap->tmp_iter_value_0 = NULL;
572  
573     // Re-raise.
574     generator_heap->exception_type = generator_heap->exception_keeper_type_1;
575     generator_heap->exception_value = generator_heap->exception_keeper_value_1;
576     generator_heap->exception_tb = generator_heap->exception_keeper_tb_1;
577     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1;
578  
579     goto frame_exception_exit_1;
580     // End of try:
581     try_end_1:;
582  
583     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
584  
585 #if PYTHON_VERSION >= 370
586     Py_CLEAR( generator->m_exc_state.exc_type );
587     Py_CLEAR( generator->m_exc_state.exc_value );
588     Py_CLEAR( generator->m_exc_state.exc_traceback );
589 #elif PYTHON_VERSION >= 300
590     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
591     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
592     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
593 #endif
594  
595     // Allow re-use of the frame again.
596     Py_DECREF( generator->m_frame );
597     goto frame_no_exception_1;
598  
599     frame_exception_exit_1:;
600  
601     // If it's not an exit exception, consider and create a traceback for it.
602     if ( !EXCEPTION_MATCH_GENERATOR( generator_heap->exception_type ) )
603     {
604         if ( generator_heap->exception_tb == NULL )
605         {
606             generator_heap->exception_tb = MAKE_TRACEBACK( generator->m_frame, generator_heap->exception_lineno );
607         }
608         else if ( generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame )
609         {
610             generator_heap->exception_tb = ADD_TRACEBACK( generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno );
611         }
612  
613         Nuitka_Frame_AttachLocals(
614             (struct Nuitka_FrameObject *)generator->m_frame,
615             generator_heap->type_description_1,
616             NULL,
617             generator_heap->var_x
618         );
619  
620  
621         // Release cached frame.
622         if ( generator->m_frame == cache_m_frame )
623         {
624             Py_DECREF( generator->m_frame );
625         }
626         cache_m_frame = NULL;
627  
628         assertFrameObject( generator->m_frame );
629     }
630  
631 #if PYTHON_VERSION >= 370
632     Py_CLEAR( generator->m_exc_state.exc_type );
633     Py_CLEAR( generator->m_exc_state.exc_value );
634     Py_CLEAR( generator->m_exc_state.exc_traceback );
635 #elif PYTHON_VERSION >= 300
636     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
637     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
638     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
639 #endif
640  
641     Py_DECREF( generator->m_frame );
642  
643     // Return the error.
644     goto try_except_handler_1;
645  
646     frame_no_exception_1:;
647     goto try_end_2;
648     // Exception handler code:
649     try_except_handler_1:;
650     generator_heap->exception_keeper_type_2 = generator_heap->exception_type;
651     generator_heap->exception_keeper_value_2 = generator_heap->exception_value;
652     generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb;
653     generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno;
654     generator_heap->exception_type = NULL;
655     generator_heap->exception_value = NULL;
656     generator_heap->exception_tb = NULL;
657     generator_heap->exception_lineno = 0;
658  
659     Py_XDECREF( generator_heap->var_x );
660     generator_heap->var_x = NULL;
661  
662     // Re-raise.
663     generator_heap->exception_type = generator_heap->exception_keeper_type_2;
664     generator_heap->exception_value = generator_heap->exception_keeper_value_2;
665     generator_heap->exception_tb = generator_heap->exception_keeper_tb_2;
666     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_2;
667  
668     goto function_exception_exit;
669     // End of try:
670     try_end_2:;
671     Py_XDECREF( generator_heap->tmp_iter_value_0 );
672     generator_heap->tmp_iter_value_0 = NULL;
673  
674     Py_XDECREF( generator_heap->var_x );
675     generator_heap->var_x = NULL;
676  
677  
678  
679     return NULL;
680  
681     function_exception_exit:
682     assert( generator_heap->exception_type );
683     RESTORE_ERROR_OCCURRED( generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb );
684  
685     return NULL;
686  
687 }
688  
689 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void )
690 {
691     return Nuitka_Generator_New(
692         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
693         module___main__,
694         const_str_angle_genexpr,
695 #if PYTHON_VERSION >= 350
696         const_str_digest_57aac74124c55d29a6f122835861daff,
697 #endif
698         codeobj_ad26b251ad716ea9c4da7b5ac89fe7b6,
699         1,
700         sizeof(struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals)
701     );
702 } 339 }
703 340
704 341
705 342
706 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 343 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )