Construct GeneratorExpressionCreation

Performance Diagrams

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