Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)17171394688.11538461538461257.0CPython 2.737005561240.03846153846155450.860284185609Nuitka (main)37005621391.96153846153845450.86019783896427Nuitka (develop)37005621543.8846153846154450.86019783896427Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)20149733088.11538461538461257.0CPython 3.849111051240.03846153846155443.88582099421524Nuitka (main)49111463391.96153846153845443.885315719339Nuitka (develop)49111463543.8846153846154443.885315719339Nuitka (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
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[19]; n 36 static PyObject *mod_consts[16];
37 #ifndef __NUITKA_NO_ASSERT__ 37 #ifndef __NUITKA_NO_ASSERT__
n 38 static Py_hash_t mod_consts_hash[19]; n 38 static Py_hash_t mod_consts_hash[16];
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(&mod_consts[0], UNTRANSLATE("__main__")); 49         loadConstantsBlob(&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 < 19; i++) { n 53         for(int i = 0; i < 16; i++) {
54             mod_consts_hash[i] = DEEP_HASH(mod_consts[i]); 54             mod_consts_hash[i] = DEEP_HASH(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__(void) { 69 void checkModuleConstants___main__(void) {
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 < 19; i++) { n 73     for(int i = 0; i < 16; i++) {
74         assert(mod_consts_hash[i] == DEEP_HASH(mod_consts[i])); 74         assert(mod_consts_hash[i] == DEEP_HASH(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_72be379a8ed0af6b33792ce7e28d013f; n
82 static PyCodeObject *codeobj_7f9937497ee4bb3273e16fb29614fea1; 81 static PyCodeObject *codeobj_7f9937497ee4bb3273e16fb29614fea1;
83 static PyCodeObject *codeobj_0509cfc6314fd37d09977414fc0bcf12; 82 static PyCodeObject *codeobj_0509cfc6314fd37d09977414fc0bcf12;
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[4]; CHECK_OBJECT(module_filename_obj); n 87     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
89     codeobj_72be379a8ed0af6b33792ce7e28d013f = MAKE_CODEOBJECT(module_filename_obj, 24, CO_GENERATOR | CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[1], mod_consts[16], NULL, 1, 0, 0);
90     codeobj_7f9937497ee4bb3273e16fb29614fea1 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], NULL, NULL, 0, 0, 0); 88     codeobj_7f9937497ee4bb3273e16fb29614fea1 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], NULL, NULL, 0, 0, 0);
91     codeobj_0509cfc6314fd37d09977414fc0bcf12 = MAKE_CODEOBJECT(module_filename_obj, 21, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[8], mod_consts[18], NULL, 0, 0, 0); 89     codeobj_0509cfc6314fd37d09977414fc0bcf12 = MAKE_CODEOBJECT(module_filename_obj, 21, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[15], NULL, 0, 0, 0);
92 } 90 }
93 91
94 // The module function declarations. 92 // The module function declarations.
n 95 static PyObject *MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(struct Nuitka_CellObject **closure); n
96  
97  
98 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 93 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
99 94
100 95
101 // The module function definitions. 96 // The module function definitions.
102 static PyObject *impl___main__$$$function__1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { 97 static PyObject *impl___main__$$$function__1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) {
106 #endif 101 #endif
107 102
108     // Local variable declarations. 103     // Local variable declarations.
109     PyObject *var_gen = NULL; 104     PyObject *var_gen = NULL;
110     PyObject *var_x = NULL; 105     PyObject *var_x = NULL;
n 111     PyObject *tmp_genexpr_1__$0 = NULL; n
112     struct Nuitka_FrameObject *frame_0509cfc6314fd37d09977414fc0bcf12; 106     struct Nuitka_FrameObject *frame_0509cfc6314fd37d09977414fc0bcf12;
113     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 107     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
114     PyObject *exception_type = NULL; 108     PyObject *exception_type = NULL;
115     PyObject *exception_value = NULL; 109     PyObject *exception_value = NULL;
116     PyTracebackObject *exception_tb = NULL; 110     PyTracebackObject *exception_tb = NULL;
124     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 118     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
125 119
126     // Actual function body. 120     // Actual function body.
127     { 121     {
128         PyObject *tmp_assign_source_1; 122         PyObject *tmp_assign_source_1;
n 129         { n
130             PyObject *tmp_assign_source_2;
131             PyObject *tmp_iter_arg_1; 123         PyObject *tmp_iter_arg_1;
132             tmp_iter_arg_1 = mod_consts[0]; 124         tmp_iter_arg_1 = mod_consts[0];
133             tmp_assign_source_2 = MAKE_ITERATOR_INFALLIBLE(tmp_iter_arg_1); 125         tmp_assign_source_1 = MAKE_ITERATOR_INFALLIBLE(tmp_iter_arg_1);
134             assert(!(tmp_assign_source_2 == NULL)); 126         assert(!(tmp_assign_source_1 == NULL));
135             assert(tmp_genexpr_1__$0 == NULL);
136             tmp_genexpr_1__$0 = tmp_assign_source_2;
137         }
138         // Tried code:
139         {
140             struct Nuitka_CellObject *tmp_closure_1[1];
141  
142             tmp_closure_1[0] = Nuitka_Cell_New0(tmp_genexpr_1__$0);
143  
144             tmp_assign_source_1 = MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(tmp_closure_1);
145  
146             goto try_return_handler_1;
147         }
148         NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
149         return NULL;
150         // Return handler code:
151         try_return_handler_1:;
152         CHECK_OBJECT(tmp_genexpr_1__$0);
153         Py_DECREF(tmp_genexpr_1__$0);
154         tmp_genexpr_1__$0 = NULL;
155         goto outline_result_1;
156         // End of try:
157         NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
158         return NULL;
159         outline_result_1:;
160         assert(var_gen == NULL); 127         assert(var_gen == NULL);
161         var_gen = tmp_assign_source_1; 128         var_gen = tmp_assign_source_1;
162     } 129     }
163     // Tried code: 130     // Tried code:
164     if (isFrameUnusable(cache_frame_0509cfc6314fd37d09977414fc0bcf12)) { 131     if (isFrameUnusable(cache_frame_0509cfc6314fd37d09977414fc0bcf12)) {
187     // Mark the frame object as in use, ref count 1 will be up for reuse. 154     // Mark the frame object as in use, ref count 1 will be up for reuse.
188     assert(Py_REFCNT(frame_0509cfc6314fd37d09977414fc0bcf12) == 2); // Frame stack 155     assert(Py_REFCNT(frame_0509cfc6314fd37d09977414fc0bcf12) == 2); // Frame stack
189 156
190     // Framed code: 157     // Framed code:
191     { 158     {
n 192         PyObject *tmp_assign_source_3; n 159         PyObject *tmp_assign_source_2;
193         PyObject *tmp_value_value_1; 160         PyObject *tmp_value_value_1;
194         CHECK_OBJECT(var_gen); 161         CHECK_OBJECT(var_gen);
195         tmp_value_value_1 = var_gen; 162         tmp_value_value_1 = var_gen;
n 196         tmp_assign_source_3 = ITERATOR_NEXT(tmp_value_value_1); n 163         tmp_assign_source_2 = ITERATOR_NEXT(tmp_value_value_1);
197         if (tmp_assign_source_3 == NULL) { 164         if (tmp_assign_source_2 == NULL) {
198             if (!ERROR_OCCURRED()) { 165             if (!ERROR_OCCURRED()) {
199                 exception_type = PyExc_StopIteration; 166                 exception_type = PyExc_StopIteration;
200                 Py_INCREF(exception_type); 167                 Py_INCREF(exception_type);
201                 exception_value = NULL; 168                 exception_value = NULL;
202                 exception_tb = NULL; 169                 exception_tb = NULL;
208             type_description_1 = "oo"; 175             type_description_1 = "oo";
209             exception_lineno = 29; 176             exception_lineno = 29;
210             goto frame_exception_exit_1; 177             goto frame_exception_exit_1;
211         } 178         }
212         assert(var_x == NULL); 179         assert(var_x == NULL);
n 213         var_x = tmp_assign_source_3; n 180         var_x = tmp_assign_source_2;
214     } 181     }
215     { 182     {
216         PyObject *tmp_value_value_2; 183         PyObject *tmp_value_value_2;
217         PyObject *tmp_next_value_1; 184         PyObject *tmp_next_value_1;
218         CHECK_OBJECT(var_gen); 185         CHECK_OBJECT(var_gen);
281 248
282     // Put the previous frame back on top. 249     // Put the previous frame back on top.
283     popFrameStack(); 250     popFrameStack();
284 251
285     // Return the error. 252     // Return the error.
n 286     goto try_except_handler_2; n 253     goto try_except_handler_1;
287 254
288     frame_no_exception_1:; 255     frame_no_exception_1:;
289     CHECK_OBJECT(var_x); 256     CHECK_OBJECT(var_x);
290     tmp_return_value = var_x; 257     tmp_return_value = var_x;
291     Py_INCREF(tmp_return_value); 258     Py_INCREF(tmp_return_value);
n 292     goto try_return_handler_2; n 259     goto try_return_handler_1;
293     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases"); 260     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
294     return NULL; 261     return NULL;
295     // Return handler code: 262     // Return handler code:
n 296     try_return_handler_2:; n 263     try_return_handler_1:;
297     CHECK_OBJECT(var_gen); 264     CHECK_OBJECT(var_gen);
298     Py_DECREF(var_gen); 265     Py_DECREF(var_gen);
299     var_gen = NULL; 266     var_gen = NULL;
300     CHECK_OBJECT(var_x); 267     CHECK_OBJECT(var_x);
301     Py_DECREF(var_x); 268     Py_DECREF(var_x);
302     var_x = NULL; 269     var_x = NULL;
303     goto function_return_exit; 270     goto function_return_exit;
304     // Exception handler code: 271     // Exception handler code:
n 305     try_except_handler_2:; n 272     try_except_handler_1:;
306     exception_keeper_type_1 = exception_type; 273     exception_keeper_type_1 = exception_type;
307     exception_keeper_value_1 = exception_value; 274     exception_keeper_value_1 = exception_value;
308     exception_keeper_tb_1 = exception_tb; 275     exception_keeper_tb_1 = exception_tb;
309     exception_keeper_lineno_1 = exception_lineno; 276     exception_keeper_lineno_1 = exception_lineno;
310     exception_type = NULL; 277     exception_type = NULL;
346    return tmp_return_value; 313    return tmp_return_value;
347 } 314 }
348 315
349 316
350 317
n 351 struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals { n
352     PyObject *var_x;
353     PyObject *tmp_iter_value_0;
354     char const *type_description_1;
355     PyObject *exception_type;
356     PyObject *exception_value;
357     PyTracebackObject *exception_tb;
358     int exception_lineno;
359     PyObject *exception_keeper_type_1;
360     PyObject *exception_keeper_value_1;
361     PyTracebackObject *exception_keeper_tb_1;
362     int exception_keeper_lineno_1;
363     PyObject *exception_keeper_type_2;
364     PyObject *exception_keeper_value_2;
365     PyTracebackObject *exception_keeper_tb_2;
366     int exception_keeper_lineno_2;
367 };
368  
369 static PyObject *__main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_context(struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value) {
370     CHECK_OBJECT(generator);
371     assert(Nuitka_Generator_Check((PyObject *)generator));
372     CHECK_OBJECT_X(yield_return_value);
373  
374     // Heap access if used.
375     struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals *generator_heap = (struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals *)generator->m_heap_storage;
376  
377     // Dispatch to yield based on return label index:
378     switch(generator->m_yield_return_index) {
379     case 1: goto yield_return_1;
380     }
381  
382     // Local variable initialization
383     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
384     static struct Nuitka_FrameObject *cache_m_frame = NULL;
385     generator_heap->var_x = NULL;
386     generator_heap->tmp_iter_value_0 = NULL;
387     generator_heap->type_description_1 = NULL;
388     generator_heap->exception_type = NULL;
389     generator_heap->exception_value = NULL;
390     generator_heap->exception_tb = NULL;
391     generator_heap->exception_lineno = 0;
392  
393     // Actual generator function body.
394     // Tried code:
395     if (isFrameUnusable(cache_m_frame)) {
396         Py_XDECREF(cache_m_frame);
397  
398 #if _DEBUG_REFCOUNTS
399         if (cache_m_frame == NULL) {
400             count_active_frame_cache_instances += 1;
401         } else {
402             count_released_frame_cache_instances += 1;
403         }
404         count_allocated_frame_cache_instances += 1;
405 #endif
406         cache_m_frame = MAKE_FUNCTION_FRAME(codeobj_72be379a8ed0af6b33792ce7e28d013f, module___main__, sizeof(void *)+sizeof(void *));
407 #if _DEBUG_REFCOUNTS
408     } else {
409         count_hit_frame_cache_instances += 1;
410 #endif
411     }
412     generator->m_frame = cache_m_frame;
413  
414     // Mark the frame object as in use, ref count 1 will be up for reuse.
415     Py_INCREF(generator->m_frame);
416     assert(Py_REFCNT(generator->m_frame) == 2); // Frame stack
417  
418 #if PYTHON_VERSION >= 0x340
419     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
420 #endif
421  
422     assert(generator->m_frame->m_frame.f_back == NULL);
423     Py_CLEAR(generator->m_frame->m_frame.f_back);
424  
425     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
426     Py_INCREF(generator->m_frame->m_frame.f_back);
427  
428     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
429     Py_INCREF(generator->m_frame);
430  
431     Nuitka_Frame_MarkAsExecuting(generator->m_frame);
432  
433 #if PYTHON_VERSION >= 0x300
434     // Accept currently existing exception as the one to publish again when we
435     // yield or yield from.
436     {
437         PyThreadState *thread_state = PyThreadState_GET();
438  
439         EXC_TYPE_F(generator) = EXC_TYPE(thread_state);
440         if (EXC_TYPE_F(generator) == Py_None) EXC_TYPE_F(generator) = NULL;
441         Py_XINCREF(EXC_TYPE_F(generator));
442         EXC_VALUE_F(generator) = EXC_VALUE(thread_state);
443         Py_XINCREF(EXC_VALUE_F(generator));
444         EXC_TRACEBACK_F(generator) = EXC_TRACEBACK(thread_state);
445         Py_XINCREF(EXC_TRACEBACK_F(generator));
446     }
447  
448 #endif
449  
450     // Framed code:
451     // Tried code:
452     loop_start_1:;
453     {
454         PyObject *tmp_next_source_1;
455         PyObject *tmp_assign_source_1;
456         CHECK_OBJECT(Nuitka_Cell_GET(generator->m_closure[0]));
457         tmp_next_source_1 = Nuitka_Cell_GET(generator->m_closure[0]);
458         tmp_assign_source_1 = ITERATOR_NEXT(tmp_next_source_1);
459         if (tmp_assign_source_1 == NULL) {
460             if (CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED()) {
461  
462                 goto loop_end_1;
463             } else {
464  
465                 FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
466                 generator_heap->type_description_1 = "No";
467                 generator_heap->exception_lineno = 24;
468                 goto try_except_handler_2;
469             }
470         }
471  
472         {
473             PyObject *old = generator_heap->tmp_iter_value_0;
474             generator_heap->tmp_iter_value_0 = tmp_assign_source_1;
475             Py_XDECREF(old);
476         }
477  
478     }
479     {
480         PyObject *tmp_assign_source_2;
481         CHECK_OBJECT(generator_heap->tmp_iter_value_0);
482         tmp_assign_source_2 = generator_heap->tmp_iter_value_0;
483         {
484             PyObject *old = generator_heap->var_x;
485             generator_heap->var_x = tmp_assign_source_2;
486             Py_INCREF(generator_heap->var_x);
487             Py_XDECREF(old);
488         }
489  
490     }
491     {
492         PyObject *tmp_expression_value_1;
493         NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
494         CHECK_OBJECT(generator_heap->var_x);
495         tmp_expression_value_1 = generator_heap->var_x;
496         Py_INCREF(tmp_expression_value_1);
497         generator->m_yield_return_index = 1;
498         return tmp_expression_value_1;
499         yield_return_1:
500         if (yield_return_value == NULL) {
501             assert(ERROR_OCCURRED());
502  
503             FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
504  
505  
506             generator_heap->exception_lineno = 24;
507             generator_heap->type_description_1 = "No";
508             goto try_except_handler_2;
509         }
510         tmp_yield_result_1 = yield_return_value;
511     }
512     if (CONSIDER_THREADING() == false) {
513         assert(ERROR_OCCURRED());
514  
515         FETCH_ERROR_OCCURRED(&generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb);
516  
517  
518         generator_heap->exception_lineno = 24;
519         generator_heap->type_description_1 = "No";
520         goto try_except_handler_2;
521     }
522     goto loop_start_1;
523     loop_end_1:;
524     goto try_end_1;
525     // Exception handler code:
526     try_except_handler_2:;
527     generator_heap->exception_keeper_type_1 = generator_heap->exception_type;
528     generator_heap->exception_keeper_value_1 = generator_heap->exception_value;
529     generator_heap->exception_keeper_tb_1 = generator_heap->exception_tb;
530     generator_heap->exception_keeper_lineno_1 = generator_heap->exception_lineno;
531     generator_heap->exception_type = NULL;
532     generator_heap->exception_value = NULL;
533     generator_heap->exception_tb = NULL;
534     generator_heap->exception_lineno = 0;
535  
536     Py_XDECREF(generator_heap->tmp_iter_value_0);
537     generator_heap->tmp_iter_value_0 = NULL;
538     // Re-raise.
539     generator_heap->exception_type = generator_heap->exception_keeper_type_1;
540     generator_heap->exception_value = generator_heap->exception_keeper_value_1;
541     generator_heap->exception_tb = generator_heap->exception_keeper_tb_1;
542     generator_heap->exception_lineno = generator_heap->exception_keeper_lineno_1;
543  
544     goto frame_exception_exit_1;
545     // End of try:
546     try_end_1:;
547  
548     Nuitka_Frame_MarkAsNotExecuting(generator->m_frame);
549  
550 #if PYTHON_VERSION >= 0x300
551     Py_CLEAR(EXC_TYPE_F(generator));
552     Py_CLEAR(EXC_VALUE_F(generator));
553     Py_CLEAR(EXC_TRACEBACK_F(generator));
554 #endif
555  
556     // Allow re-use of the frame again.
557     Py_DECREF(generator->m_frame);
558     goto frame_no_exception_1;
559  
560     frame_exception_exit_1:;
561  
562     // If it's not an exit exception, consider and create a traceback for it.
563     if (!EXCEPTION_MATCH_GENERATOR(generator_heap->exception_type)) {
564         if (generator_heap->exception_tb == NULL) {
565             generator_heap->exception_tb = MAKE_TRACEBACK(generator->m_frame, generator_heap->exception_lineno);
566         } else if (generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame) {
567             generator_heap->exception_tb = ADD_TRACEBACK(generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno);
568         }
569  
570         Nuitka_Frame_AttachLocals(
571             generator->m_frame,
572             generator_heap->type_description_1,
573             NULL,
574             generator_heap->var_x
575         );
576  
577  
578         // Release cached frame if used for exception.
579         if (generator->m_frame == cache_m_frame) {
580 #if _DEBUG_REFCOUNTS
581             count_active_frame_cache_instances -= 1;
582             count_released_frame_cache_instances += 1;
583 #endif
584  
585             Py_DECREF(cache_m_frame);
586             cache_m_frame = NULL;
587         }
588  
589         assertFrameObject(generator->m_frame);
590     }
591  
592 #if PYTHON_VERSION >= 0x300
593     Py_CLEAR(EXC_TYPE_F(generator));
594     Py_CLEAR(EXC_VALUE_F(generator));
595     Py_CLEAR(EXC_TRACEBACK_F(generator));
596 #endif
597  
598     Py_DECREF(generator->m_frame);
599  
600     // Return the error.
601     goto try_except_handler_1;
602  
603     frame_no_exception_1:;
604     goto try_end_2;
605     // Exception handler code:
606     try_except_handler_1:;
607     generator_heap->exception_keeper_type_2 = generator_heap->exception_type;
608     generator_heap->exception_keeper_value_2 = generator_heap->exception_value;
609     generator_heap->exception_keeper_tb_2 = generator_heap->exception_tb;
610     generator_heap->exception_keeper_lineno_2 = generator_heap->exception_lineno;
611     generator_heap->exception_type = NULL;
612     generator_heap->exception_value = NULL;
613     generator_heap->exception_tb = NULL;
614     generator_heap->exception_lineno = 0;
615  
616     Py_XDECREF(generator_heap->var_x);
617     generator_heap->var_x = NULL;
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     Py_XDECREF(generator_heap->var_x);
630     generator_heap->var_x = NULL;
631  
632  
633     return NULL;
634  
635     function_exception_exit:
636     assert(generator_heap->exception_type);
637     RESTORE_ERROR_OCCURRED(generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb);
638  
639     return NULL;
640  
641 }
642  
643 static PyObject *MAKE_GENERATOR___main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr(struct Nuitka_CellObject **closure) {
644     return Nuitka_Generator_New(
645         __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_context,
646         module___main__,
647         mod_consts[1],
648 #if PYTHON_VERSION >= 0x350
649         mod_consts[2],
650 #endif
651         codeobj_72be379a8ed0af6b33792ce7e28d013f,
652         closure,
653         1,
654         sizeof(struct __main__$$$function__1_calledRepeatedly$$$genexpr__1_genexpr_locals)
655     );
656 }
657  
658  
659  
660 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() { 318 static PyObject *MAKE_FUNCTION___main__$$$function__1_calledRepeatedly() {
661     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 319     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
662         impl___main__$$$function__1_calledRepeatedly, 320         impl___main__$$$function__1_calledRepeatedly,
n 663         mod_consts[8], n 321         mod_consts[6],
664 #if PYTHON_VERSION >= 0x300 322 #if PYTHON_VERSION >= 0x300
665         NULL, 323         NULL,
666 #endif 324 #endif
667         codeobj_0509cfc6314fd37d09977414fc0bcf12, 325         codeobj_0509cfc6314fd37d09977414fc0bcf12,
668         NULL, 326         NULL,
1043 701
1044     // Module code. 702     // Module code.
1045     { 703     {
1046         PyObject *tmp_assign_source_1; 704         PyObject *tmp_assign_source_1;
1047         tmp_assign_source_1 = Py_None; 705         tmp_assign_source_1 = Py_None;
n 1048         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_1); n 706         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
1049     } 707     }
1050     { 708     {
1051         PyObject *tmp_assign_source_2; 709         PyObject *tmp_assign_source_2;
n 1052         tmp_assign_source_2 = mod_consts[4]; n 710         tmp_assign_source_2 = mod_consts[2];
1053         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_2); 711         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
1054     } 712     }
1055     { 713     {
1056         PyObject *tmp_assign_source_3; 714         PyObject *tmp_assign_source_3;
1057         tmp_assign_source_3 = Py_None; 715         tmp_assign_source_3 = Py_None;
n 1058         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_3); n 716         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
1059     } 717     }
1060     { 718     {
1061         PyObject *tmp_assign_source_4; 719         PyObject *tmp_assign_source_4;
1062         tmp_assign_source_4 = PyDict_New(); 720         tmp_assign_source_4 = PyDict_New();
n 1063         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_4); n 721         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
1064     } 722     }
1065     { 723     {
1066         PyObject *tmp_assign_source_5; 724         PyObject *tmp_assign_source_5;
1067 725
1068 726
1069         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly(); 727         tmp_assign_source_5 = MAKE_FUNCTION___main__$$$function__1_calledRepeatedly();
1070 728
n 1071         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_5); n 729         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
1072     } 730     }
1073     { 731     {
1074         PyObject *tmp_assign_source_6; 732         PyObject *tmp_assign_source_6;
1075         PyObject *tmp_name_value_1; 733         PyObject *tmp_name_value_1;
1076         PyObject *tmp_globals_arg_value_1; 734         PyObject *tmp_globals_arg_value_1;
1077         PyObject *tmp_locals_arg_value_1; 735         PyObject *tmp_locals_arg_value_1;
1078         PyObject *tmp_fromlist_value_1; 736         PyObject *tmp_fromlist_value_1;
1079         PyObject *tmp_level_value_1; 737         PyObject *tmp_level_value_1;
n 1080         tmp_name_value_1 = mod_consts[9]; n 738         tmp_name_value_1 = mod_consts[7];
1081         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 739         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
1082         tmp_locals_arg_value_1 = Py_None; 740         tmp_locals_arg_value_1 = Py_None;
1083         tmp_fromlist_value_1 = Py_None; 741         tmp_fromlist_value_1 = Py_None;
n 1084         tmp_level_value_1 = mod_consts[10]; n 742         tmp_level_value_1 = mod_consts[8];
1085         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1, tmp_level_value_1); 743         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1, tmp_level_value_1);
1086         assert(!(tmp_assign_source_6 == NULL)); 744         assert(!(tmp_assign_source_6 == NULL));
n 1087         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_6); n 745         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_6);
1088     } 746     }
1089     // Frame without reuse. 747     // Frame without reuse.
1090     frame_7f9937497ee4bb3273e16fb29614fea1 = MAKE_MODULE_FRAME(codeobj_7f9937497ee4bb3273e16fb29614fea1, module___main__); 748     frame_7f9937497ee4bb3273e16fb29614fea1 = MAKE_MODULE_FRAME(codeobj_7f9937497ee4bb3273e16fb29614fea1, module___main__);
1091 749
1092     // Push the new frame as the currently active one, and we should be exclusively 750     // Push the new frame as the currently active one, and we should be exclusively
1097     // Framed code: 755     // Framed code:
1098     { 756     {
1099         PyObject *tmp_assign_source_7; 757         PyObject *tmp_assign_source_7;
1100         PyObject *tmp_iter_arg_1; 758         PyObject *tmp_iter_arg_1;
1101         PyObject *tmp_called_instance_1; 759         PyObject *tmp_called_instance_1;
n 1102         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[9]); n 760         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
1103 761
1104         if (unlikely(tmp_called_instance_1 == NULL)) { 762         if (unlikely(tmp_called_instance_1 == NULL)) {
n 1105             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[9]); n 763             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[7]);
1106         } 764         }
1107 765
1108         assert(!(tmp_called_instance_1 == NULL)); 766         assert(!(tmp_called_instance_1 == NULL));
1109         frame_7f9937497ee4bb3273e16fb29614fea1->m_frame.f_lineno = 35; 767         frame_7f9937497ee4bb3273e16fb29614fea1->m_frame.f_lineno = 35;
1110         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 768         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(
1111             tmp_called_instance_1, 769             tmp_called_instance_1,
n 1112             mod_consts[11], n 770             mod_consts[9],
1113             &PyTuple_GET_ITEM(mod_consts[12], 0) 771             &PyTuple_GET_ITEM(mod_consts[10], 0)
1114         ); 772         );
1115 773
1116         if (tmp_iter_arg_1 == NULL) { 774         if (tmp_iter_arg_1 == NULL) {
1117             assert(ERROR_OCCURRED()); 775             assert(ERROR_OCCURRED());
1118 776
1168     } 826     }
1169     { 827     {
1170         PyObject *tmp_assign_source_9; 828         PyObject *tmp_assign_source_9;
1171         CHECK_OBJECT(tmp_for_loop_1__iter_value); 829         CHECK_OBJECT(tmp_for_loop_1__iter_value);
1172         tmp_assign_source_9 = tmp_for_loop_1__iter_value; 830         tmp_assign_source_9 = tmp_for_loop_1__iter_value;
n 1173         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[13], tmp_assign_source_9); n 831         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_9);
1174     } 832     }
1175     { 833     {
1176         PyObject *tmp_called_value_1; 834         PyObject *tmp_called_value_1;
1177         PyObject *tmp_call_result_1; 835         PyObject *tmp_call_result_1;
n 1178         tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 836         tmp_called_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]);
1179 837
1180         if (unlikely(tmp_called_value_1 == NULL)) { 838         if (unlikely(tmp_called_value_1 == NULL)) {
n 1181             tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[8]); n 839             tmp_called_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[6]);
1182         } 840         }
1183 841
1184         if (tmp_called_value_1 == NULL) { 842         if (tmp_called_value_1 == NULL) {
1185             assert(ERROR_OCCURRED()); 843             assert(ERROR_OCCURRED());
1186 844
1249     Py_DECREF(tmp_for_loop_1__for_iterator); 907     Py_DECREF(tmp_for_loop_1__for_iterator);
1250     tmp_for_loop_1__for_iterator = NULL; 908     tmp_for_loop_1__for_iterator = NULL;
1251     { 909     {
1252         PyObject *tmp_called_value_2; 910         PyObject *tmp_called_value_2;
1253         PyObject *tmp_call_result_2; 911         PyObject *tmp_call_result_2;
n 1254         tmp_called_value_2 = LOOKUP_BUILTIN(mod_consts[14]); n 912         tmp_called_value_2 = LOOKUP_BUILTIN(mod_consts[12]);
1255         assert(tmp_called_value_2 != NULL); 913         assert(tmp_called_value_2 != NULL);
1256         frame_7f9937497ee4bb3273e16fb29614fea1->m_frame.f_lineno = 38; 914         frame_7f9937497ee4bb3273e16fb29614fea1->m_frame.f_lineno = 38;
t 1257         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_value_2, mod_consts[15]); t 915         tmp_call_result_2 = CALL_FUNCTION_WITH_POSARGS1(tmp_called_value_2, mod_consts[13]);
1258 916
1259         if (tmp_call_result_2 == NULL) { 917         if (tmp_call_result_2 == NULL) {
1260             assert(ERROR_OCCURRED()); 918             assert(ERROR_OCCURRED());
1261 919
1262             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 920             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);