Construct GeneratorExpressionCreation
Performance Diagrams
Source Code with Construct
for x in itertools.repeat(None, 50000): calledRepeatedly() print("OK.") # Python test originally created or extracted from other peoples work. The # parts from me are licensed as below. It is at least Free Software where # it's copied from other people. In these cases, that will normally be # indicated. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
Source Code without Construct
for x in itertools.repeat(None, 50000): calledRepeatedly() print("OK.") # Python test originally created or extracted from other peoples work. The # parts from me are licensed as below. It is at least Free Software where # it's copied from other people. In these cases, that will normally be # indicated. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
Context Diff of Source Code
Construct | Baseline | ||||
---|---|---|---|---|---|
5 | 5 | ||||
6 | 6 | ||||
7 | def calledRepeatedly(): | 7 | def calledRepeatedly(): | ||
8 | # We measure making a generator iterator step or not. | 8 | # We measure making a generator iterator step or not. | ||
9 | # construct_begin | 9 | # construct_begin | ||
n | 10 | gen = (x for x in range(3)) | n | 10 | |
11 | # construct_alternative | 11 | # construct_alternative | ||
t | 12 | t | 12 | gen = iter((1, 2, 3)) | |
13 | 13 | # construct_end | |||
14 | 14 | ||||
15 | x = next(gen) | 15 | x = next(gen) | ||
16 | next(gen) | 16 | next(gen) | ||
17 | 17 | ||||
18 | return x | 18 | return x |
Context Diff of Generated Code
Construct | Baseline | ||||
---|---|---|---|---|---|
31 | 31 | ||||
32 | PyObject *module___main__; | 32 | PyObject *module___main__; | ||
33 | PyDictObject *moduledict___main__; | 33 | PyDictObject *moduledict___main__; | ||
34 | 34 | ||||
35 | /* The declarations of module constants used, if any. */ | 35 | /* The declarations of module constants used, if any. */ | ||
n | 36 | static PyObject *mod_consts[15]; | n | 36 | static PyObject *mod_consts[12]; |
37 | #ifndef __NUITKA_NO_ASSERT__ | 37 | #ifndef __NUITKA_NO_ASSERT__ | ||
n | 38 | static Py_hash_t mod_consts_hash[15]; | n | 38 | static Py_hash_t mod_consts_hash[12]; |
39 | #endif | 39 | #endif | ||
40 | 40 | ||||
41 | static PyObject *module_filename_obj = NULL; | 41 | static PyObject *module_filename_obj = NULL; | ||
42 | 42 | ||||
43 | /* Indicator if this modules private constants were created yet. */ | 43 | /* Indicator if this modules private constants were created yet. */ | ||
48 | if (constants_created == false) { | 48 | if (constants_created == false) { | ||
49 | loadConstantsBlob(tstate, &mod_consts[0], UNTRANSLATE("__main__")); | 49 | loadConstantsBlob(tstate, &mod_consts[0], UNTRANSLATE("__main__")); | ||
50 | constants_created = true; | 50 | constants_created = true; | ||
51 | 51 | ||||
52 | #ifndef __NUITKA_NO_ASSERT__ | 52 | #ifndef __NUITKA_NO_ASSERT__ | ||
n | 53 | for (int i = 0; i < 15; i++) { | n | 53 | for (int i = 0; i < 12; i++) { |
54 | mod_consts_hash[i] = DEEP_HASH(tstate, mod_consts[i]); | 54 | mod_consts_hash[i] = DEEP_HASH(tstate, mod_consts[i]); | ||
55 | } | 55 | } | ||
56 | #endif | 56 | #endif | ||
57 | } | 57 | } | ||
58 | } | 58 | } | ||
68 | #ifndef __NUITKA_NO_ASSERT__ | 68 | #ifndef __NUITKA_NO_ASSERT__ | ||
69 | void checkModuleConstants___main__(PyThreadState *tstate) { | 69 | void checkModuleConstants___main__(PyThreadState *tstate) { | ||
70 | // The module may not have been used at all, then ignore this. | 70 | // The module may not have been used at all, then ignore this. | ||
71 | if (constants_created == false) return; | 71 | if (constants_created == false) return; | ||
72 | 72 | ||||
n | 73 | for (int i = 0; i < 15; i++) { | n | 73 | for (int i = 0; i < 12; i++) { |
74 | assert(mod_consts_hash[i] == DEEP_HASH(tstate, mod_consts[i])); | 74 | assert(mod_consts_hash[i] == DEEP_HASH(tstate, mod_consts[i])); | ||
75 | CHECK_OBJECT_DEEP(mod_consts[i]); | 75 | CHECK_OBJECT_DEEP(mod_consts[i]); | ||
76 | } | 76 | } | ||
77 | } | 77 | } | ||
78 | #endif | 78 | #endif | ||
79 | 79 | ||||
80 | // The module code objects. | 80 | // The module code objects. | ||
n | 81 | static PyCodeObject *codeobj_9379d2902b9d8ccbfbba1f1af2a7f488; | n | ||
82 | static PyCodeObject *codeobj_77b3939ab8047cbd74469631e04c4c36; | 81 | static PyCodeObject *codeobj_77b3939ab8047cbd74469631e04c4c36; | ||
83 | static PyCodeObject *codeobj_4f83efe8f6771b82bd34ed157d85cfae; | 82 | static PyCodeObject *codeobj_4f83efe8f6771b82bd34ed157d85cfae; | ||
84 | /* For use in "MainProgram.c". */ | 83 | /* For use in "MainProgram.c". */ | ||
85 | PyCodeObject *codeobj_main = NULL; | 84 | PyCodeObject *codeobj_main = NULL; | ||
86 | 85 | ||||
87 | static void createModuleCodeObjects(void) { | 86 | static void createModuleCodeObjects(void) { | ||
n | 88 | module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); | n | 87 | module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj); |
89 | codeobj_9379d2902b9d8ccbfbba1f1af2a7f488 = MAKE_CODE_OBJECT(module_filename_obj, 10, CO_GENERATOR | CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[1], mod_consts[11], mod_consts[12], NULL, 1, 0, 0); | ||||
90 | codeobj_77b3939ab8047cbd74469631e04c4c36 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[13], NULL, NULL, 0, 0, 0); | 88 | codeobj_77b3939ab8047cbd74469631e04c4c36 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[10], mod_consts[10], NULL, NULL, 0, 0, 0); | ||
91 | codeobj_main = codeobj_77b3939ab8047cbd74469631e04c4c36; | 89 | codeobj_main = codeobj_77b3939ab8047cbd74469631e04c4c36; | ||
n | 92 | codeobj_4f83efe8f6771b82bd34ed157d85cfae = MAKE_CODE_OBJECT(module_filename_obj, 7, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[6], mod_consts[14], NULL, 0, 0, 0); | n | 90 | codeobj_4f83efe8f6771b82bd34ed157d85cfae = MAKE_CODE_OBJECT(module_filename_obj, 7, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[5], mod_consts[11], NULL, 0, 0, 0); |
93 | } | 91 | } | ||
94 | 92 | ||||
95 | // The module function declarations. | 93 | // The module function declarations. | ||
n | 96 | static PyObject *MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(struct Nuitka_CellObject **closure); | n | ||
97 | |||||
98 | |||||
99 | static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); | 94 | static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); | ||
100 | 95 | ||||
101 | 96 | ||||
102 | // The module function definitions. | 97 | // The module function definitions. | ||
103 | static PyObject *impl___main__$$$function__1_calledRepeatedly(PyThreadState *tstate, struct Nuitka_FunctionObject const *self, PyObject **python_pars) { | 98 | static PyObject *impl___main__$$$function__1_calledRepeatedly(PyThreadState *tstate, struct Nuitka_FunctionObject const *self, PyObject **python_pars) { | ||
107 | #endif | 102 | #endif | ||
108 | 103 | ||||
109 | // Local variable declarations. | 104 | // Local variable declarations. | ||
110 | PyObject *var_gen = NULL; | 105 | PyObject *var_gen = NULL; | ||
111 | PyObject *var_x = NULL; | 106 | PyObject *var_x = NULL; | ||
n | 112 | PyObject *tmp_genexpr_1__$0 = NULL; | n | ||
113 | struct Nuitka_FrameObject *frame_4f83efe8f6771b82bd34ed157d85cfae; | 107 | struct Nuitka_FrameObject *frame_4f83efe8f6771b82bd34ed157d85cfae; | ||
114 | NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; | 108 | NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; | ||
115 | PyObject *exception_type = NULL; | 109 | PyObject *exception_type = NULL; | ||
116 | PyObject *exception_value = NULL; | 110 | PyObject *exception_value = NULL; | ||
117 | PyTracebackObject *exception_tb = NULL; | 111 | PyTracebackObject *exception_tb = NULL; | ||
125 | NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; | 119 | NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; | ||
126 | 120 | ||||
127 | // Actual function body. | 121 | // Actual function body. | ||
128 | { | 122 | { | ||
129 | PyObject *tmp_assign_source_1; | 123 | PyObject *tmp_assign_source_1; | ||
n | 130 | { | n | ||
131 | PyObject *tmp_assign_source_2; | ||||
132 | PyObject *tmp_iter_arg_1; | 124 | PyObject *tmp_iter_arg_1; | ||
133 | tmp_iter_arg_1 = mod_consts[0]; | 125 | tmp_iter_arg_1 = mod_consts[0]; | ||
134 | tmp_assign_source_2 = MAKE_ITERATOR_INFALLIBLE(tmp_iter_arg_1); | 126 | tmp_assign_source_1 = MAKE_ITERATOR_INFALLIBLE(tmp_iter_arg_1); | ||
135 | assert(!(tmp_assign_source_2 == NULL)); | 127 | assert(!(tmp_assign_source_1 == NULL)); | ||
136 | assert(tmp_genexpr_1__$0 == NULL); | ||||
137 | tmp_genexpr_1__$0 = tmp_assign_source_2; | ||||
138 | } | ||||
139 | // Tried code: | ||||
140 | { | ||||
141 | struct Nuitka_CellObject *tmp_closure_1[1]; | ||||
142 | |||||
143 | tmp_closure_1[0] = Nuitka_Cell_New0(tmp_genexpr_1__$0); | ||||
144 | |||||
145 | tmp_assign_source_1 = MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(tmp_closure_1); | ||||
146 | |||||
147 | goto try_return_handler_1; | ||||
148 | } | ||||
149 | NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); | ||||
150 | return NULL; | ||||
151 | // Return handler code: | ||||
152 | try_return_handler_1:; | ||||
153 | CHECK_OBJECT(tmp_genexpr_1__$0); | ||||
154 | Py_DECREF(tmp_genexpr_1__$0); | ||||
155 | tmp_genexpr_1__$0 = NULL; | ||||
156 | goto outline_result_1; | ||||
157 | // End of try: | ||||
158 | NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); | ||||
159 | return NULL; | ||||
160 | outline_result_1:; | ||||
161 | assert(var_gen == NULL); | 128 | assert(var_gen == NULL); | ||
162 | var_gen = tmp_assign_source_1; | 129 | var_gen = tmp_assign_source_1; | ||
163 | } | 130 | } | ||
164 | // Tried code: | 131 | // Tried code: | ||
165 | if (isFrameUnusable(cache_frame_4f83efe8f6771b82bd34ed157d85cfae)) { | 132 | if (isFrameUnusable(cache_frame_4f83efe8f6771b82bd34ed157d85cfae)) { | ||
188 | pushFrameStackCompiledFrame(tstate, frame_4f83efe8f6771b82bd34ed157d85cfae); | 155 | pushFrameStackCompiledFrame(tstate, frame_4f83efe8f6771b82bd34ed157d85cfae); | ||
189 | assert(Py_REFCNT(frame_4f83efe8f6771b82bd34ed157d85cfae) == 2); | 156 | assert(Py_REFCNT(frame_4f83efe8f6771b82bd34ed157d85cfae) == 2); | ||
190 | 157 | ||||
191 | // Framed code: | 158 | // Framed code: | ||
192 | { | 159 | { | ||
n | 193 | PyObject *tmp_assign_source_3; | n | 160 | PyObject *tmp_assign_source_2; |
194 | PyObject *tmp_value_value_1; | 161 | PyObject *tmp_value_value_1; | ||
195 | CHECK_OBJECT(var_gen); | 162 | CHECK_OBJECT(var_gen); | ||
196 | tmp_value_value_1 = var_gen; | 163 | tmp_value_value_1 = var_gen; | ||
n | 197 | tmp_assign_source_3 = ITERATOR_NEXT(tmp_value_value_1); | n | 164 | tmp_assign_source_2 = ITERATOR_NEXT(tmp_value_value_1); |
198 | if (tmp_assign_source_3 == NULL) { | 165 | if (tmp_assign_source_2 == NULL) { | ||
199 | if (!HAS_ERROR_OCCURRED(tstate)) { | 166 | if (!HAS_ERROR_OCCURRED(tstate)) { | ||
200 | exception_type = PyExc_StopIteration; | 167 | exception_type = PyExc_StopIteration; | ||
201 | Py_INCREF(exception_type); | 168 | Py_INCREF(exception_type); | ||
202 | exception_value = NULL; | 169 | exception_value = NULL; | ||
203 | exception_tb = NULL; | 170 | exception_tb = NULL; | ||
209 | type_description_1 = "oo"; | 176 | type_description_1 = "oo"; | ||
210 | exception_lineno = 15; | 177 | exception_lineno = 15; | ||
211 | goto frame_exception_exit_1; | 178 | goto frame_exception_exit_1; | ||
212 | } | 179 | } | ||
213 | assert(var_x == NULL); | 180 | assert(var_x == NULL); | ||
n | 214 | var_x = tmp_assign_source_3; | n | 181 | var_x = tmp_assign_source_2; |
215 | } | 182 | } | ||
216 | { | 183 | { | ||
217 | PyObject *tmp_value_value_2; | 184 | PyObject *tmp_value_value_2; | ||
218 | PyObject *tmp_next_value_1; | 185 | PyObject *tmp_next_value_1; | ||
219 | CHECK_OBJECT(var_gen); | 186 | CHECK_OBJECT(var_gen); | ||
274 | 241 | ||||
275 | // Put the previous frame back on top. | 242 | // Put the previous frame back on top. | ||
276 | popFrameStack(tstate); | 243 | popFrameStack(tstate); | ||
277 | 244 | ||||
278 | // Return the error. | 245 | // Return the error. | ||
n | 279 | goto try_except_handler_2; | n | 246 | goto try_except_handler_1; |
280 | frame_no_exception_1:; | 247 | frame_no_exception_1:; | ||
281 | CHECK_OBJECT(var_x); | 248 | CHECK_OBJECT(var_x); | ||
282 | tmp_return_value = var_x; | 249 | tmp_return_value = var_x; | ||
283 | Py_INCREF(tmp_return_value); | 250 | Py_INCREF(tmp_return_value); | ||
n | 284 | goto try_return_handler_2; | n | 251 | goto try_return_handler_1; |
285 | NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); | 252 | NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); | ||
286 | return NULL; | 253 | return NULL; | ||
287 | // Return handler code: | 254 | // Return handler code: | ||
n | 288 | try_return_handler_2:; | n | 255 | try_return_handler_1:; |
289 | CHECK_OBJECT(var_gen); | 256 | CHECK_OBJECT(var_gen); | ||
290 | Py_DECREF(var_gen); | 257 | Py_DECREF(var_gen); | ||
291 | var_gen = NULL; | 258 | var_gen = NULL; | ||
292 | CHECK_OBJECT(var_x); | 259 | CHECK_OBJECT(var_x); | ||
293 | Py_DECREF(var_x); | 260 | Py_DECREF(var_x); | ||
294 | var_x = NULL; | 261 | var_x = NULL; | ||
295 | goto function_return_exit; | 262 | goto function_return_exit; | ||
296 | // Exception handler code: | 263 | // Exception handler code: | ||
n | 297 | try_except_handler_2:; | n | 264 | try_except_handler_1:; |
298 | exception_keeper_type_1 = exception_type; | 265 | exception_keeper_type_1 = exception_type; | ||
299 | exception_keeper_value_1 = exception_value; | 266 | exception_keeper_value_1 = exception_value; | ||
300 | exception_keeper_tb_1 = exception_tb; | 267 | exception_keeper_tb_1 = exception_tb; | ||
301 | exception_keeper_lineno_1 = exception_lineno; | 268 | exception_keeper_lineno_1 = exception_lineno; | ||
302 | exception_type = NULL; | 269 | exception_type = NULL; | ||
339 | return tmp_return_value; | 306 | return tmp_return_value; | ||
340 | } | 307 | } | ||
341 | 308 | ||||
342 | 309 | ||||
343 | 310 | ||||
n | 344 | #if 1 | n | ||
345 | struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals { | ||||
346 | PyObject *var_x; | ||||
347 | PyObject *tmp_iter_value_0; | ||||
348 | char const *type_description_1; | ||||
349 | PyObject *exception_type; | ||||
350 | PyObject *exception_value; | ||||
351 | PyTracebackObject *exception_tb; | ||||
352 | int exception_lineno; | ||||
353 | PyObject *exception_keeper_type_1; | ||||
354 | PyObject *exception_keeper_value_1; | ||||
355 | PyTracebackObject *exception_keeper_tb_1; | ||||
356 | int exception_keeper_lineno_1; | ||||
357 | PyObject *exception_keeper_type_2; | ||||
358 | PyObject *exception_keeper_value_2; | ||||
359 | PyTracebackObject *exception_keeper_tb_2; | ||||
360 | int exception_keeper_lineno_2; | ||||
361 | }; | ||||
362 | #endif | ||||
363 | |||||
364 | static PyObject *__main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_context(PyThreadState *tstate, struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value) { | ||||
365 | CHECK_OBJECT(generator); | ||||
366 | assert(Nuitka_Generator_Check((PyObject *)generator)); | ||||
367 | CHECK_OBJECT_X(yield_return_value); | ||||
368 | |||||
369 | #if 1 | ||||
370 | // Heap access. | ||||
371 | struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals *generator_heap = (struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals *)generator->m_heap_storage; | ||||
372 | #endif | ||||
373 | |||||
374 | // Dispatch to yield based on return label index: | ||||
375 | switch(generator->m_yield_return_index) { | ||||
376 | case 1: goto yield_return_1; | ||||
377 | } | ||||
378 | |||||
379 | // Local variable initialization | ||||
380 | NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; | ||||
381 | static struct Nuitka_FrameObject *cache_m_frame = NULL; | ||||
382 | generator_heap->var_x = NULL; | ||||
383 | generator_heap->tmp_iter_value_0 = NULL; | ||||
384 | generator_heap->type_description_1 = NULL; | ||||
385 | generator_heap->exception_type = NULL; | ||||
386 | generator_heap->exception_value = NULL; | ||||
387 | generator_heap->exception_tb = NULL; | ||||
388 | generator_heap->exception_lineno = 0; | ||||
389 | |||||
390 | // Actual generator function body. | ||||
391 | // Tried code: | ||||
392 | if (isFrameUnusable(cache_m_frame)) { | ||||
393 | Py_XDECREF(cache_m_frame); | ||||
394 | |||||
395 | #if _DEBUG_REFCOUNTS | ||||
396 | if (cache_m_frame == NULL) { | ||||
397 | count_active_frame_cache_instances += 1; | ||||
398 | } else { | ||||
399 | count_released_frame_cache_instances += 1; | ||||
400 | } | ||||
401 | count_allocated_frame_cache_instances += 1; | ||||
402 | #endif | ||||
403 | cache_m_frame = MAKE_FUNCTION_FRAME(tstate, codeobj_9379d2902b9d8ccbfbba1f1af2a7f488, module___main__, sizeof(void *)+sizeof(void *)); | ||||
404 | #if _DEBUG_REFCOUNTS | ||||
405 | } else { | ||||
406 | count_hit_frame_cache_instances += 1; | ||||
407 | #endif | ||||
408 | } | ||||
409 | |||||
410 | assert(cache_m_frame->m_type_description == NULL); | ||||
411 | generator->m_frame = cache_m_frame; | ||||
412 | // Mark the frame object as in use, ref count 1 will be up for reuse. | ||||
413 | Py_INCREF(generator->m_frame); | ||||
414 | assert(Py_REFCNT(generator->m_frame) == 2); // Frame stack | ||||
415 | |||||
416 | |||||
417 | assert(generator->m_frame->m_frame.f_back == NULL); | ||||
418 | |||||
419 | // Push the new frame as the currently active one, and we should be exclusively | ||||
420 | // owning it. | ||||
421 | pushFrameStackGeneratorCompiledFrame(tstate, generator->m_frame); | ||||
422 | assert(Py_REFCNT(generator->m_frame) == 2); | ||||
423 | |||||
424 | // Framed code: | ||||
425 | // Tried code: | ||||
426 | loop_start_1:; | ||||
427 | { | ||||
428 | PyObject *tmp_next_source_1; | ||||
429 | PyObject *tmp_assign_source_1; | ||||
430 | CHECK_OBJECT(Nuitka_Cell_GET(generator->m_closure[0])); | ||||
431 | tmp_next_source_1 = Nuitka_Cell_GET(generator->m_closure[0]); | ||||
432 | tmp_assign_source_1 = ITERATOR_NEXT(tmp_next_source_1); | ||||
433 | if (tmp_assign_source_1 == NULL) { | ||||
434 | if (CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED(tstate)) { | ||||
435 | |||||
436 | goto loop_end_1; | ||||
437 | } else { | ||||
438 | |||||
439 | FETCH_ERROR_OCCURRED(tstate, &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb); | ||||
440 | generator_heap->type_description_1 = "No"; | ||||
441 | generator_heap->exception_lineno = 10; | ||||
442 | goto try_except_handler_2; | ||||
443 | } | ||||
444 | } | ||||
445 | |||||
446 | { | ||||
447 | PyObject *old = generator_heap->tmp_iter_value_0; | ||||
448 | generator_heap->tmp_iter_value_0 = tmp_assign_source_1; | ||||
449 | Py_XDECREF(old); | ||||
450 | } | ||||
451 | |||||
452 | } | ||||
453 | { | ||||
454 | PyObject *tmp_assign_source_2; | ||||
455 | CHECK_OBJECT(generator_heap->tmp_iter_value_0); | ||||
456 | tmp_assign_source_2 = generator_heap->tmp_iter_value_0; | ||||
457 | { | ||||
458 | PyObject *old = generator_heap->var_x; | ||||
459 | generator_heap->var_x = tmp_assign_source_2; | ||||
460 | Py_INCREF(generator_heap->var_x); | ||||
461 | Py_XDECREF(old); | ||||
462 | } | ||||
463 | |||||
464 | } | ||||
465 | { | ||||
466 | PyObject *tmp_expression_value_1; | ||||
467 | NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1; | ||||
468 | CHECK_OBJECT(generator_heap->var_x); | ||||
469 | tmp_expression_value_1 = generator_heap->var_x; | ||||
470 | Py_INCREF(tmp_expression_value_1); | ||||
471 | generator->m_yield_return_index = 1; | ||||
472 | return tmp_expression_value_1; | ||||
473 | yield_return_1: | ||||
474 | if (yield_return_value == NULL) { | ||||
475 | assert(HAS_ERROR_OCCURRED(tstate)); | ||||
476 | |||||
477 | FETCH_ERROR_OCCURRED(tstate, &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb); | ||||
478 | |||||
479 | |||||
480 | generator_heap->exception_lineno = 10; | ||||
481 | generator_heap->type_description_1 = "No"; | ||||
482 | goto try_except_handler_2; | ||||
483 | } | ||||
484 | tmp_yield_result_1 = yield_return_value; | ||||
485 | Py_DECREF(tmp_yield_result_1); | ||||
486 | } | ||||
487 | if (CONSIDER_THREADING(tstate) == false) { | ||||
488 | assert(HAS_ERROR_OCCURRED(tstate)); | ||||
489 | |||||
490 | FETCH_ERROR_OCCURRED(tstate, &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb); | ||||
491 | |||||
492 | |||||
493 | generator_heap->exception_lineno = 10; | ||||
494 | generator_heap->type_description_1 = "No"; | ||||
495 | goto try_except_handler_2; | ||||
496 | } | ||||
497 | goto loop_start_1; | ||||
498 | loop_end_1:; | ||||
499 | goto try_end_1; | ||||
500 | // Exception handler code: | ||||
501 | try_except_handler_2:; | ||||
502 | generator_heap->exception_keeper_type_1 = generator_heap->exception_type; | ||||
503 | generator_heap->exception_keeper_value_1 = generator_heap->exception_value; | ||||
504 | generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb; | ||||
505 | generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno; | ||||
506 | generator_heap->exception_type = NULL; | ||||
507 | generator_heap->exception_value = NULL; | ||||
508 | generator_heap->exception_tb = NULL; | ||||
509 | generator_heap->exception_lineno = 0; | ||||
510 | |||||
511 | Py_XDECREF(generator_heap->tmp_iter_value_0); | ||||
512 | generator_heap->tmp_iter_value_0 = NULL; | ||||
513 | // Re-raise. | ||||
514 | generator_heap->exception_type = generator_heap->exception_keeper_type_1; | ||||
515 | generator_heap->exception_value = generator_heap->exception_keeper_value_1; | ||||
516 | generator_heap->exception_tb = generator_heap->exception_keeper_tb_1; | ||||
517 | generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1; | ||||
518 | |||||
519 | goto frame_exception_exit_1; | ||||
520 | // End of try: | ||||
521 | try_end_1:; | ||||
522 | |||||
523 | |||||
524 | |||||
525 | goto frame_no_exception_1; | ||||
526 | frame_exception_exit_1:; | ||||
527 | |||||
528 | // If it's not an exit exception, consider and create a traceback for it. | ||||
529 | if (!EXCEPTION_MATCH_GENERATOR(tstate, generator_heap->exception_type)) { | ||||
530 | if (generator_heap->exception_tb == NULL) { | ||||
531 | generator_heap->exception_tb = MAKE_TRACEBACK(generator->m_frame, generator_heap->exception_lineno); | ||||
532 | } else if (generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame) { | ||||
533 | generator_heap->exception_tb = ADD_TRACEBACK(generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno); | ||||
534 | } | ||||
535 | |||||
536 | Nuitka_Frame_AttachLocals( | ||||
537 | generator->m_frame, | ||||
538 | generator_heap->type_description_1, | ||||
539 | NULL, | ||||
540 | generator_heap->var_x | ||||
541 | ); | ||||
542 | |||||
543 | |||||
544 | // Release cached frame if used for exception. | ||||
545 | if (generator->m_frame == cache_m_frame) { | ||||
546 | #if _DEBUG_REFCOUNTS | ||||
547 | count_active_frame_cache_instances -= 1; | ||||
548 | count_released_frame_cache_instances += 1; | ||||
549 | #endif | ||||
550 | |||||
551 | Py_DECREF(cache_m_frame); | ||||
552 | cache_m_frame = NULL; | ||||
553 | } | ||||
554 | |||||
555 | assertFrameObject(generator->m_frame); | ||||
556 | } | ||||
557 | |||||
558 | #if PYTHON_VERSION >= 0x300 | ||||
559 | #if PYTHON_VERSION < 0x3b0 | ||||
560 | Py_CLEAR(EXC_TYPE_F(generator)); | ||||
561 | #endif | ||||
562 | Py_CLEAR(EXC_VALUE_F(generator)); | ||||
563 | #if PYTHON_VERSION < 0x3b0 | ||||
564 | Py_CLEAR(EXC_TRACEBACK_F(generator)); | ||||
565 | #endif | ||||
566 | #endif | ||||
567 | |||||
568 | // Return the error. | ||||
569 | goto try_except_handler_1; | ||||
570 | |||||
571 | frame_no_exception_1:; | ||||
572 | goto try_end_2; | ||||
573 | // Exception handler code: | ||||
574 | try_except_handler_1:; | ||||
575 | generator_heap->exception_keeper_type_2 = generator_heap->exception_type; | ||||
576 | generator_heap->exception_keeper_value_2 = generator_heap->exception_value; | ||||
577 | generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb; | ||||
578 | generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno; | ||||
579 | generator_heap->exception_type = NULL; | ||||
580 | generator_heap->exception_value = NULL; | ||||
581 | generator_heap->exception_tb = NULL; | ||||
582 | generator_heap->exception_lineno = 0; | ||||
583 | |||||
584 | Py_XDECREF(generator_heap->var_x); | ||||
585 | generator_heap->var_x = NULL; | ||||
586 | // Re-raise. | ||||
587 | generator_heap->exception_type = generator_heap->exception_keeper_type_2; | ||||
588 | generator_heap->exception_value = generator_heap->exception_keeper_value_2; | ||||
589 | generator_heap->exception_tb = generator_heap->exception_keeper_tb_2; | ||||
590 | generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_2; | ||||
591 | |||||
592 | goto function_exception_exit; | ||||
593 | // End of try: | ||||
594 | try_end_2:; | ||||
595 | Py_XDECREF(generator_heap->tmp_iter_value_0); | ||||
596 | generator_heap->tmp_iter_value_0 = NULL; | ||||
597 | Py_XDECREF(generator_heap->var_x); | ||||
598 | generator_heap->var_x = NULL; | ||||
599 | |||||
600 | |||||
601 | return NULL; | ||||
602 | |||||
603 | function_exception_exit: | ||||
604 | |||||
605 | assert(generator_heap->exception_type); | ||||
606 | RESTORE_ERROR_OCCURRED(tstate, generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb); | ||||
607 | |||||
608 | return NULL; | ||||
609 | |||||
610 | } | ||||
611 | |||||
612 | static PyObject *MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(struct Nuitka_CellObject **closure) { | ||||
613 | return Nuitka_Generator_New( | ||||
614 | __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_context, | ||||
615 | module___main__, | ||||
616 | mod_consts[1], | ||||
617 | #if PYTHON_VERSION >= 0x350 | ||||
618 | NULL, | ||||
619 | #endif | ||||
620 | codeobj_9379d2902b9d8ccbfbba1f1af2a7f488, | ||||
621 | closure, | ||||
622 | 1, | ||||
623 | #if 1 | ||||
624 | sizeof(struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals) | ||||
625 | #else | ||||
626 | 0 | ||||
627 | #endif | ||||
628 | ); | ||||
629 | } | ||||
630 | |||||
631 | |||||
632 | |||||
633 | static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { | 311 | static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { | ||
634 | struct Nuitka_FunctionObject *result = Nuitka_Function_New( | 312 | struct Nuitka_FunctionObject *result = Nuitka_Function_New( | ||
635 | impl___main__$$$function__1_calledRepeatedly, | 313 | impl___main__$$$function__1_calledRepeatedly, | ||
n | 636 | mod_consts[6], | n | 314 | mod_consts[5], |
637 | #if PYTHON_VERSION >= 0x300 | 315 | #if PYTHON_VERSION >= 0x300 | ||
638 | NULL, | 316 | NULL, | ||
639 | #endif | 317 | #endif | ||
640 | codeobj_4f83efe8f6771b82bd34ed157d85cfae, | 318 | codeobj_4f83efe8f6771b82bd34ed157d85cfae, | ||
641 | NULL, | 319 | NULL, | ||
1021 | 699 | ||||
1022 | // Module code. | 700 | // Module code. | ||
1023 | { | 701 | { | ||
1024 | PyObject *tmp_assign_source_1; | 702 | PyObject *tmp_assign_source_1; | ||
1025 | tmp_assign_source_1 = Py_None; | 703 | tmp_assign_source_1 = Py_None; | ||
n | 1026 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); | n | 704 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1); |
1027 | } | 705 | } | ||
1028 | { | 706 | { | ||
1029 | PyObject *tmp_assign_source_2; | 707 | PyObject *tmp_assign_source_2; | ||
n | 1030 | tmp_assign_source_2 = mod_consts[3]; | n | 708 | tmp_assign_source_2 = mod_consts[2]; |
1031 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); | 709 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2); | ||
1032 | } | 710 | } | ||
1033 | frame_77b3939ab8047cbd74469631e04c4c36 = MAKE_MODULE_FRAME(codeobj_77b3939ab8047cbd74469631e04c4c36, module___main__); | 711 | frame_77b3939ab8047cbd74469631e04c4c36 = MAKE_MODULE_FRAME(codeobj_77b3939ab8047cbd74469631e04c4c36, module___main__); | ||
1034 | 712 | ||||
1035 | // Push the new frame as the currently active one, and we should be exclusively | 713 | // Push the new frame as the currently active one, and we should be exclusively | ||
1036 | // owning it. | 714 | // owning it. | ||
1042 | PyObject *tmp_assign_source_3; | 720 | PyObject *tmp_assign_source_3; | ||
1043 | PyObject *tmp_name_value_1; | 721 | PyObject *tmp_name_value_1; | ||
1044 | PyObject *tmp_globals_arg_value_1; | 722 | PyObject *tmp_globals_arg_value_1; | ||
1045 | PyObject *tmp_locals_arg_value_1; | 723 | PyObject *tmp_locals_arg_value_1; | ||
1046 | PyObject *tmp_fromlist_value_1; | 724 | PyObject *tmp_fromlist_value_1; | ||
n | 1047 | tmp_name_value_1 = mod_consts[5]; | n | 725 | tmp_name_value_1 = mod_consts[4]; |
1048 | tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; | 726 | tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; | ||
1049 | tmp_locals_arg_value_1 = Py_None; | 727 | tmp_locals_arg_value_1 = Py_None; | ||
1050 | tmp_fromlist_value_1 = Py_None; | 728 | tmp_fromlist_value_1 = Py_None; | ||
1051 | frame_77b3939ab8047cbd74469631e04c4c36->m_frame.f_lineno = 4; | 729 | frame_77b3939ab8047cbd74469631e04c4c36->m_frame.f_lineno = 4; | ||
1052 | tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); | 730 | tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); | ||
1058 | 736 | ||||
1059 | exception_lineno = 4; | 737 | exception_lineno = 4; | ||
1060 | 738 | ||||
1061 | goto frame_exception_exit_1; | 739 | goto frame_exception_exit_1; | ||
1062 | } | 740 | } | ||
n | 1063 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); | n | 741 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3); |
1064 | } | 742 | } | ||
1065 | { | 743 | { | ||
1066 | PyObject *tmp_assign_source_4; | 744 | PyObject *tmp_assign_source_4; | ||
1067 | 745 | ||||
1068 | 746 | ||||
1069 | tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); | 747 | tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); | ||
1070 | 748 | ||||
n | 1071 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); | n | 749 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4); |
1072 | } | 750 | } | ||
1073 | { | 751 | { | ||
1074 | PyObject *tmp_assign_source_5; | 752 | PyObject *tmp_assign_source_5; | ||
1075 | PyObject *tmp_iter_arg_1; | 753 | PyObject *tmp_iter_arg_1; | ||
1076 | PyObject *tmp_called_instance_1; | 754 | PyObject *tmp_called_instance_1; | ||
n | 1077 | tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]); | n | 755 | tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]); |
1078 | 756 | ||||
1079 | if (unlikely(tmp_called_instance_1 == NULL)) { | 757 | if (unlikely(tmp_called_instance_1 == NULL)) { | ||
n | 1080 | tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]); | n | 758 | tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[4]); |
1081 | } | 759 | } | ||
1082 | 760 | ||||
1083 | assert(!(tmp_called_instance_1 == NULL)); | 761 | assert(!(tmp_called_instance_1 == NULL)); | ||
1084 | frame_77b3939ab8047cbd74469631e04c4c36->m_frame.f_lineno = 21; | 762 | frame_77b3939ab8047cbd74469631e04c4c36->m_frame.f_lineno = 21; | ||
1085 | tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( | 763 | tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( | ||
1086 | tstate, | 764 | tstate, | ||
1087 | tmp_called_instance_1, | 765 | tmp_called_instance_1, | ||
n | 1088 | mod_consts[7], | n | 766 | mod_consts[6], |
1089 | &PyTuple_GET_ITEM(mod_consts[8], 0) | 767 | &PyTuple_GET_ITEM(mod_consts[7], 0) | ||
1090 | ); | 768 | ); | ||
1091 | 769 | ||||
1092 | if (tmp_iter_arg_1 == NULL) { | 770 | if (tmp_iter_arg_1 == NULL) { | ||
1093 | assert(HAS_ERROR_OCCURRED(tstate)); | 771 | assert(HAS_ERROR_OCCURRED(tstate)); | ||
1094 | 772 | ||||
1144 | } | 822 | } | ||
1145 | { | 823 | { | ||
1146 | PyObject *tmp_assign_source_7; | 824 | PyObject *tmp_assign_source_7; | ||
1147 | CHECK_OBJECT(tmp_for_loop_1__iter_value); | 825 | CHECK_OBJECT(tmp_for_loop_1__iter_value); | ||
1148 | tmp_assign_source_7 = tmp_for_loop_1__iter_value; | 826 | tmp_assign_source_7 = tmp_for_loop_1__iter_value; | ||
n | 1149 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_7); | n | 827 | UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_7); |
1150 | } | 828 | } | ||
1151 | { | 829 | { | ||
1152 | PyObject *tmp_called_value_1; | 830 | PyObject *tmp_called_value_1; | ||
1153 | PyObject *tmp_call_result_1; | 831 | PyObject *tmp_call_result_1; | ||
n | 1154 | tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]); | n | 832 | tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]); |
1155 | 833 | ||||
1156 | if (unlikely(tmp_called_value_1 == NULL)) { | 834 | if (unlikely(tmp_called_value_1 == NULL)) { | ||
n | 1157 | tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[6]); | n | 835 | tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[5]); |
1158 | } | 836 | } | ||
1159 | 837 | ||||
1160 | if (tmp_called_value_1 == NULL) { | 838 | if (tmp_called_value_1 == NULL) { | ||
1161 | assert(HAS_ERROR_OCCURRED(tstate)); | 839 | assert(HAS_ERROR_OCCURRED(tstate)); | ||
1162 | 840 | ||||
1222 | Py_XDECREF(tmp_for_loop_1__iter_value); | 900 | Py_XDECREF(tmp_for_loop_1__iter_value); | ||
1223 | tmp_for_loop_1__iter_value = NULL; | 901 | tmp_for_loop_1__iter_value = NULL; | ||
1224 | CHECK_OBJECT(tmp_for_loop_1__for_iterator); | 902 | CHECK_OBJECT(tmp_for_loop_1__for_iterator); | ||
1225 | Py_DECREF(tmp_for_loop_1__for_iterator); | 903 | Py_DECREF(tmp_for_loop_1__for_iterator); | ||
1226 | tmp_for_loop_1__for_iterator = NULL; | 904 | tmp_for_loop_1__for_iterator = NULL; | ||
t | 1227 | tmp_print_value = mod_consts[10]; | t | 905 | tmp_print_value = mod_consts[9]; |
1228 | tmp_result = PRINT_ITEM(tmp_print_value); | 906 | tmp_result = PRINT_ITEM(tmp_print_value); | ||
1229 | if (tmp_result == false) { | 907 | if (tmp_result == false) { | ||
1230 | assert(HAS_ERROR_OCCURRED(tstate)); | 908 | assert(HAS_ERROR_OCCURRED(tstate)); | ||
1231 | 909 | ||||
1232 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | 910 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); |