Construct GeneratorExpressionCreation

Performance Diagrams

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