Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19790943488.11538461538461257.0CPython 2.744223792240.03846153846155448.8962919811711Nuitka (master)44224123391.96153846153845448.8958786850959Nuitka (develop)44125539543.8846153846154449.0189734895454Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)24304858788.11538461538461257.0CPython 3.555791495240.03846153846155447.3903613788072Nuitka (master)55840307391.96153846153845447.34073263460124Nuitka (develop)55741136543.8846153846154447.4415630081088Nuitka (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;
44 static PyObject *const_str_digest_60daa1a7e178af022cbccdfae62fa6ad; 39 static PyObject *const_str_digest_60daa1a7e178af022cbccdfae62fa6ad;
n 45 static PyObject *const_int_pos_3; n
46 static PyObject *const_str_plain_gen; 40 static PyObject *const_str_plain_gen;
47 static PyObject *const_int_pos_50000; 41 static PyObject *const_int_pos_50000;
n n 42 static PyObject *const_int_pos_3;
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_60daa1a7e178af022cbccdfae62fa6ad = UNSTREAM_STRING_ASCII(&constant_bin[ 47 ], 52, 0);
72     const_str_plain_False = UNSTREAM_STRING_ASCII(&constant_bin[ 82 ], 5, 1); 68     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); 69     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
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_b9c4baf879ebd882d40843df3a4dead7 = UNSTREAM_STRING_ASCII(&constant_bin[ 87 ], 2, 1);
77     const_str_digest_60daa1a7e178af022cbccdfae62fa6ad = UNSTREAM_STRING_ASCII(&constant_bin[ 89 ], 52, 0);
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_d48b84014ccf6284edbcd014a0ec8b24; n
115 static PyCodeObject *codeobj_5242cfb54f9105c1501d0e15d57f57b5; 107 static PyCodeObject *codeobj_5242cfb54f9105c1501d0e15d57f57b5;
116 static PyCodeObject *codeobj_b20c4f64c247583da536094aee6a7671; 108 static PyCodeObject *codeobj_b20c4f64c247583da536094aee6a7671;
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_60daa1a7e178af022cbccdfae62fa6ad; 114     module_filename_obj = const_str_digest_60daa1a7e178af022cbccdfae62fa6ad;
n 123     codeobj_d48b84014ccf6284edbcd014a0ec8b24 = 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_5242cfb54f9105c1501d0e15d57f57b5 = MAKE_CODEOBJ(module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE); 115     codeobj_5242cfb54f9105c1501d0e15d57f57b5 = MAKE_CODEOBJ(module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE);
125     codeobj_b20c4f64c247583da536094aee6a7671 = 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_b20c4f64c247583da536094aee6a7671 = 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) {
140 #endif 128 #endif
141 129
142     // Local variable declarations. 130     // Local variable declarations.
143     PyObject *var_gen = NULL; 131     PyObject *var_gen = NULL;
144     PyObject *var_x = NULL; 132     PyObject *var_x = NULL;
n 145     PyObject *tmp_genexpr_1__$0 = NULL; n
146     struct Nuitka_FrameObject *frame_b20c4f64c247583da536094aee6a7671; 133     struct Nuitka_FrameObject *frame_b20c4f64c247583da536094aee6a7671;
147     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 134     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
148     PyObject *exception_type = NULL; 135     PyObject *exception_type = NULL;
149     PyObject *exception_value = NULL; 136     PyObject *exception_value = NULL;
150     PyTracebackObject *exception_tb = NULL; 137     PyTracebackObject *exception_tb = NULL;
157     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 144     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
158 145
159     // Actual function body. 146     // Actual function body.
160     { 147     {
161         PyObject *tmp_assign_source_1; 148         PyObject *tmp_assign_source_1;
n 162         { n
163             PyObject *tmp_assign_source_2;
164             PyObject *tmp_iter_arg_1; 149         PyObject *tmp_iter_arg_1;
165             tmp_iter_arg_1 = const_xrange_0_3; 150         tmp_iter_arg_1 = const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
166             tmp_assign_source_2 = MAKE_ITERATOR(tmp_iter_arg_1); 151         tmp_assign_source_1 = MAKE_ITERATOR(tmp_iter_arg_1);
167             assert(!(tmp_assign_source_2 == NULL)); 152         assert(!(tmp_assign_source_1 == NULL));
168             assert(tmp_genexpr_1__$0 == NULL);
169             tmp_genexpr_1__$0 = tmp_assign_source_2;
170         }
171         // Tried code:
172         tmp_assign_source_1 = __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker();
173  
174         ((struct Nuitka_GeneratorObject *)tmp_assign_source_1)->m_closure[0] = PyCell_NEW0(tmp_genexpr_1__$0);
175  
176  
177         goto try_return_handler_1;
178         // tried codes exits in all cases
179         NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
180         return NULL;
181         // Return handler code:
182         try_return_handler_1:;
183         CHECK_OBJECT((PyObject *)tmp_genexpr_1__$0);
184         Py_DECREF(tmp_genexpr_1__$0);
185         tmp_genexpr_1__$0 = NULL;
186  
187         goto outline_result_1;
188         // End of try:
189         CHECK_OBJECT((PyObject *)tmp_genexpr_1__$0);
190         Py_DECREF(tmp_genexpr_1__$0);
191         tmp_genexpr_1__$0 = NULL;
192  
193         // Return statement must have exited already.
194         NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
195         return NULL;
196         outline_result_1:;
197         assert(var_gen == NULL); 153         assert(var_gen == NULL);
198         var_gen = tmp_assign_source_1; 154         var_gen = tmp_assign_source_1;
199     } 155     }
200     // Tried code: 156     // Tried code:
201     MAKE_OR_REUSE_FRAME(cache_frame_b20c4f64c247583da536094aee6a7671, codeobj_b20c4f64c247583da536094aee6a7671, module___main__, sizeof(void *)+sizeof(void *)); 157     MAKE_OR_REUSE_FRAME(cache_frame_b20c4f64c247583da536094aee6a7671, codeobj_b20c4f64c247583da536094aee6a7671, module___main__, sizeof(void *)+sizeof(void *));
207     // Mark the frame object as in use, ref count 1 will be up for reuse. 163     // Mark the frame object as in use, ref count 1 will be up for reuse.
208     assert(Py_REFCNT(frame_b20c4f64c247583da536094aee6a7671) == 2); // Frame stack 164     assert(Py_REFCNT(frame_b20c4f64c247583da536094aee6a7671) == 2); // Frame stack
209 165
210     // Framed code: 166     // Framed code:
211     { 167     {
n 212         PyObject *tmp_assign_source_3; n 168         PyObject *tmp_assign_source_2;
213         PyObject *tmp_value_name_1; 169         PyObject *tmp_value_name_1;
214         CHECK_OBJECT(var_gen); 170         CHECK_OBJECT(var_gen);
215         tmp_value_name_1 = var_gen; 171         tmp_value_name_1 = var_gen;
n 216         tmp_assign_source_3 = ITERATOR_NEXT(tmp_value_name_1); n 172         tmp_assign_source_2 = ITERATOR_NEXT(tmp_value_name_1);
217         if (tmp_assign_source_3 == NULL) { 173         if (tmp_assign_source_2 == NULL) {
218             if (!ERROR_OCCURRED()) { 174             if (!ERROR_OCCURRED()) {
219                 exception_type = PyExc_StopIteration; 175                 exception_type = PyExc_StopIteration;
220                 Py_INCREF(exception_type); 176                 Py_INCREF(exception_type);
221                 exception_value = NULL; 177                 exception_value = NULL;
222                 exception_tb = NULL; 178                 exception_tb = NULL;
228             type_description_1 = "oo"; 184             type_description_1 = "oo";
229             exception_lineno = 29; 185             exception_lineno = 29;
230             goto frame_exception_exit_1; 186             goto frame_exception_exit_1;
231         } 187         }
232         assert(var_x == NULL); 188         assert(var_x == NULL);
n 233         var_x = tmp_assign_source_3; n 189         var_x = tmp_assign_source_2;
234     } 190     }
235     { 191     {
236         PyObject *tmp_value_name_2; 192         PyObject *tmp_value_name_2;
237         PyObject *tmp_next_value_1; 193         PyObject *tmp_next_value_1;
238         CHECK_OBJECT(var_gen); 194         CHECK_OBJECT(var_gen);
297 253
298     // Put the previous frame back on top. 254     // Put the previous frame back on top.
299     popFrameStack(); 255     popFrameStack();
300 256
301     // Return the error. 257     // Return the error.
n 302     goto try_except_handler_2; n 258     goto try_except_handler_1;
303 259
304     frame_no_exception_1:; 260     frame_no_exception_1:;
305     CHECK_OBJECT(var_x); 261     CHECK_OBJECT(var_x);
306     tmp_return_value = var_x; 262     tmp_return_value = var_x;
307     Py_INCREF(tmp_return_value); 263     Py_INCREF(tmp_return_value);
n 308     goto try_return_handler_2; n 264     goto try_return_handler_1;
309     // tried codes exits in all cases 265     // tried codes exits in all cases
310     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 266     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
311     return NULL; 267     return NULL;
312     // Return handler code: 268     // Return handler code:
n 313     try_return_handler_2:; n 269     try_return_handler_1:;
314     CHECK_OBJECT((PyObject *)var_gen); 270     CHECK_OBJECT((PyObject *)var_gen);
315     Py_DECREF(var_gen); 271     Py_DECREF(var_gen);
316     var_gen = NULL; 272     var_gen = NULL;
317 273
318     CHECK_OBJECT((PyObject *)var_x); 274     CHECK_OBJECT((PyObject *)var_x);
319     Py_DECREF(var_x); 275     Py_DECREF(var_x);
320     var_x = NULL; 276     var_x = NULL;
321 277
322     goto function_return_exit; 278     goto function_return_exit;
323     // Exception handler code: 279     // Exception handler code:
n 324     try_except_handler_2:; n 280     try_except_handler_1:;
325     exception_keeper_type_1 = exception_type; 281     exception_keeper_type_1 = exception_type;
326     exception_keeper_value_1 = exception_value; 282     exception_keeper_value_1 = exception_value;
327     exception_keeper_tb_1 = exception_tb; 283     exception_keeper_tb_1 = exception_tb;
328     exception_keeper_lineno_1 = exception_lineno; 284     exception_keeper_lineno_1 = exception_lineno;
329     exception_type = NULL; 285     exception_type = NULL;
364    // Actual function exit with return value, making sure we did not make 320    // Actual function exit with return value, making sure we did not make
365    // the error status worse despite non-NULL return. 321    // the error status worse despite non-NULL return.
366    CHECK_OBJECT(tmp_return_value); 322    CHECK_OBJECT(tmp_return_value);
367    assert(had_error || !ERROR_OCCURRED()); 323    assert(had_error || !ERROR_OCCURRED());
368    return tmp_return_value; 324    return tmp_return_value;
t 369 } t
370  
371  
372  
373 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
374     PyObject *var_x;
375     PyObject *tmp_iter_value_0;
376     char const *type_description_1;
377     PyObject *exception_type;
378     PyObject *exception_value;
379     PyTracebackObject *exception_tb;
380     int exception_lineno;
381     PyObject *exception_keeper_type_1;
382     PyObject *exception_keeper_value_1;
383     PyTracebackObject *exception_keeper_tb_1;
384     int exception_keeper_lineno_1;
385     PyObject *exception_keeper_type_2;
386     PyObject *exception_keeper_value_2;
387     PyTracebackObject *exception_keeper_tb_2;
388     int exception_keeper_lineno_2;
389 };
390  
391 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value ) {
392     CHECK_OBJECT((PyObject *)generator);
393     assert(Nuitka_Generator_Check( (PyObject *)generator ));
394  
395     // Heap access if used.
396     struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *generator_heap = (struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals *)generator->m_heap_storage;
397  
398     // Dispatch to yield based on return label index:
399     switch(generator->m_yield_return_index) {
400     case 1: goto yield_return_1;
401     }
402  
403     // Local variable initialization
404     static struct Nuitka_FrameObject *cache_m_frame = NULL;
405     generator_heap->var_x = NULL;
406     generator_heap->tmp_iter_value_0 = NULL;
407     generator_heap->type_description_1 = NULL;
408     generator_heap->exception_type = NULL;
409     generator_heap->exception_value = NULL;
410     generator_heap->exception_tb = NULL;
411     generator_heap->exception_lineno = 0;
412  
413     // Actual generator function body.
414     // Tried code:
415     MAKE_OR_REUSE_FRAME(cache_m_frame, codeobj_d48b84014ccf6284edbcd014a0ec8b24, module___main__, sizeof(void *)+sizeof(void *));
416     generator->m_frame = cache_m_frame;
417  
418     // Mark the frame object as in use, ref count 1 will be up for reuse.
419     Py_INCREF(generator->m_frame);
420     assert(Py_REFCNT(generator->m_frame) == 2); // Frame stack
421  
422 #if PYTHON_VERSION >= 340
423     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
424 #endif
425  
426     Py_CLEAR(generator->m_frame->m_frame.f_back);
427  
428     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
429     Py_INCREF(generator->m_frame->m_frame.f_back);
430  
431     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
432     Py_INCREF(generator->m_frame);
433  
434     Nuitka_Frame_MarkAsExecuting(generator->m_frame);
435  
436 #if PYTHON_VERSION >= 300
437     // Accept currently existing exception as the one to publish again when we
438     // yield or yield from.
439     {
440         PyThreadState *thread_state = PyThreadState_GET();
441  
442         EXC_TYPE_F(generator) = EXC_TYPE(thread_state);
443         if (EXC_TYPE_F(generator) == Py_None) EXC_TYPE_F(generator) = NULL;
444         Py_XINCREF(EXC_TYPE_F(generator));
445         EXC_VALUE_F(generator) = EXC_VALUE(thread_state);
446         Py_XINCREF(EXC_VALUE_F(generator));
447         EXC_TRACEBACK_F(generator) = EXC_TRACEBACK(thread_state);
448         Py_XINCREF(EXC_TRACEBACK_F(generator));
449     }
450  
451 #endif
452  
453     // Framed code:
454     // Tried code:
455     loop_start_1:;
456     {
457         PyObject *tmp_next_source_1;
458         PyObject *tmp_assign_source_1;
459         CHECK_OBJECT(PyCell_GET(generator->m_closure[0]));
460         tmp_next_source_1 = PyCell_GET(generator->m_closure[0]);
461         tmp_assign_source_1 = ITERATOR_NEXT(tmp_next_source_1);
462         if (tmp_assign_source_1 == NULL) {
463             if (CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED()) {
464  
465                 goto loop_end_1;
466             } else {
467  
468                 FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
469                 generator_heap->type_description_1 = "No";
470                 generator_heap->exception_lineno = 24;
471                 goto try_except_handler_2;
472             }
473         }
474  
475         {
476             PyObject *old = generator_heap->tmp_iter_value_0;
477             generator_heap->tmp_iter_value_0 = tmp_assign_source_1;
478             Py_XDECREF(old);
479         }
480  
481     }
482     {
483         PyObject *tmp_assign_source_2;
484         CHECK_OBJECT(generator_heap->tmp_iter_value_0);
485         tmp_assign_source_2 = generator_heap->tmp_iter_value_0;
486         {
487             PyObject *old = generator_heap->var_x;
488             generator_heap->var_x = tmp_assign_source_2;
489             Py_INCREF(generator_heap->var_x);
490             Py_XDECREF(old);
491         }
492  
493     }
494     {
495         PyObject *tmp_expression_name_1;
496         NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
497         CHECK_OBJECT(generator_heap->var_x);
498         tmp_expression_name_1 = generator_heap->var_x;
499         Py_INCREF(tmp_expression_name_1);
500         generator->m_yield_return_index = 1;
501         return tmp_expression_name_1;
502         yield_return_1:
503         if (yield_return_value == NULL) {
504             assert(ERROR_OCCURRED());
505  
506             FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
507  
508  
509             generator_heap->exception_lineno = 24;
510             generator_heap->type_description_1 = "No";
511             goto try_except_handler_2;
512         }
513         tmp_yield_result_1 = yield_return_value;
514     }
515     if (CONSIDER_THREADING() == false) {
516         assert(ERROR_OCCURRED());
517  
518         FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
519  
520  
521         generator_heap->exception_lineno = 24;
522         generator_heap->type_description_1 = "No";
523         goto try_except_handler_2;
524     }
525     goto loop_start_1;
526     loop_end_1:;
527     goto try_end_1;
528     // Exception handler code:
529     try_except_handler_2:;
530     generator_heap->exception_keeper_type_1 = generator_heap->exception_type;
531     generator_heap->exception_keeper_value_1 = generator_heap->exception_value;
532     generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb;
533     generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno;
534     generator_heap->exception_type = NULL;
535     generator_heap->exception_value = NULL;
536     generator_heap->exception_tb = NULL;
537     generator_heap->exception_lineno = 0;
538  
539     Py_XDECREF(generator_heap->tmp_iter_value_0);
540     generator_heap->tmp_iter_value_0 = NULL;
541  
542     // Re-raise.
543     generator_heap->exception_type = generator_heap->exception_keeper_type_1;
544     generator_heap->exception_value = generator_heap->exception_keeper_value_1;
545     generator_heap->exception_tb = generator_heap->exception_keeper_tb_1;
546     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1;
547  
548     goto frame_exception_exit_1;
549     // End of try:
550     try_end_1:;
551  
552     Nuitka_Frame_MarkAsNotExecuting(generator->m_frame);
553  
554 #if PYTHON_VERSION >= 300
555     Py_CLEAR(EXC_TYPE_F(generator));
556     Py_CLEAR(EXC_VALUE_F(generator));
557     Py_CLEAR(EXC_TRACEBACK_F(generator));
558 #endif
559  
560     // Allow re-use of the frame again.
561     Py_DECREF(generator->m_frame);
562     goto frame_no_exception_1;
563  
564     frame_exception_exit_1:;
565  
566     // If it's not an exit exception, consider and create a traceback for it.
567     if (!EXCEPTION_MATCH_GENERATOR(generator_heap->exception_type)) {
568         if (generator_heap->exception_tb == NULL) {
569             generator_heap->exception_tb = MAKE_TRACEBACK(generator->m_frame, generator_heap->exception_lineno);
570         } else if (generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame) {
571             generator_heap->exception_tb = ADD_TRACEBACK(generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno);
572         }
573  
574         Nuitka_Frame_AttachLocals(
575             (struct Nuitka_FrameObject *)generator->m_frame,
576             generator_heap->type_description_1,
577             NULL,
578             generator_heap->var_x
579         );
580  
581  
582         // Release cached frame.
583         if (generator->m_frame == cache_m_frame) {
584             Py_DECREF(generator->m_frame);
585         }
586         cache_m_frame = NULL;
587  
588         assertFrameObject(generator->m_frame);
589     }
590  
591 #if PYTHON_VERSION >= 300
592     Py_CLEAR(EXC_TYPE_F(generator));
593     Py_CLEAR(EXC_VALUE_F(generator));
594     Py_CLEAR(EXC_TRACEBACK_F(generator));
595 #endif
596  
597     Py_DECREF(generator->m_frame);
598  
599     // Return the error.
600     goto try_except_handler_1;
601  
602     frame_no_exception_1:;
603     goto try_end_2;
604     // Exception handler code:
605     try_except_handler_1:;
606     generator_heap->exception_keeper_type_2 = generator_heap->exception_type;
607     generator_heap->exception_keeper_value_2 = generator_heap->exception_value;
608     generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb;
609     generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno;
610     generator_heap->exception_type = NULL;
611     generator_heap->exception_value = NULL;
612     generator_heap->exception_tb = NULL;
613     generator_heap->exception_lineno = 0;
614  
615     Py_XDECREF(generator_heap->var_x);
616     generator_heap->var_x = NULL;
617  
618     // Re-raise.
619     generator_heap->exception_type = generator_heap->exception_keeper_type_2;
620     generator_heap->exception_value = generator_heap->exception_keeper_value_2;
621     generator_heap->exception_tb = generator_heap->exception_keeper_tb_2;
622     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_2;
623  
624     goto function_exception_exit;
625     // End of try:
626     try_end_2:;
627     Py_XDECREF(generator_heap->tmp_iter_value_0);
628     generator_heap->tmp_iter_value_0 = NULL;
629  
630     Py_XDECREF(generator_heap->var_x);
631     generator_heap->var_x = NULL;
632  
633  
634  
635     return NULL;
636  
637     function_exception_exit:
638     assert(generator_heap->exception_type);
639     RESTORE_ERROR_OCCURRED(generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb);
640  
641     return NULL;
642  
643 }
644  
645 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void )
646 {
647     return Nuitka_Generator_New(
648         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
649         module___main__,
650         const_str_angle_genexpr,
651 #if PYTHON_VERSION >= 350
652         const_str_digest_57aac74124c55d29a6f122835861daff,
653 #endif
654         codeobj_d48b84014ccf6284edbcd014a0ec8b24,
655         1,
656         sizeof(struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals)
657     );
658 } 325 }
659 326
660 327
661 328
662 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() { 329 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() {