Construct FunctionCreationGeneratorClosure

Performance Diagrams

Construct FunctionCreationGeneratorClosure 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)5030159888.95192307692307257.0CPython 2.712501121242.31730769230768442.70144456444507Nuitka (master)12502694395.6826923076923442.69371692724354Nuitka (develop)12501818549.0480769230769442.6980204302242Nuitka (factory)Construct FunctionCreationGeneratorClosureTicks Construct FunctionCreationGeneratorClosure 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5684294988.95192307692307257.0CPython 3.514555172242.31730769230768440.8391649575502Nuitka (master)14552109395.6826923076923440.8524808469682Nuitka (develop)14547692549.0480769230769440.8716830289987Nuitka (factory)Construct FunctionCreationGeneratorClosureTicks

Source Code with Construct

module_var = None

def calledRepeatedly():
    # We measure making a local function that will remain unused.
    closure_var = module_var

# construct_begin
    def empty():
        yield closure_var

# construct_alternative



    return empty, closure_var


import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_var = None

def calledRepeatedly():
    # We measure making a local function that will remain unused.
    closure_var = module_var

# construct_begin



# construct_alternative
    empty = 1
# construct_end

    return empty, closure_var


import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25     closure_var = module_var 25     closure_var = module_var
26 26
27 # construct_begin 27 # construct_begin
n 28     def empty(): n 28  
29         yield closure_var 29  
30 30
31 # construct_alternative 31 # construct_alternative
t 32   t 32     empty = 1
33   33 # construct_end
34 34
35     return empty, closure_var 35     return empty, closure_var
36 36
37 37
38 import itertools 38 import itertools

Context Diff of Generated Code


Construct
Baseline
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. */
34 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
n 35 static PyObject *const_tuple_str_plain_closure_var_tuple; n
36 static PyObject *const_str_plain_module_var; 35 static PyObject *const_str_plain_module_var;
37 static PyObject *const_str_digest_870771c64f3015e44351e054d4d79ee7; 36 static PyObject *const_str_digest_870771c64f3015e44351e054d4d79ee7;
n n 37 extern PyObject *const_int_pos_1;
38 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
39 static PyObject *const_str_plain_closure_var; 39 static PyObject *const_str_plain_closure_var;
40 extern PyObject *const_int_0; 40 extern PyObject *const_int_0;
41 static PyObject *const_tuple_str_plain_closure_var_str_plain_empty_tuple; 41 static PyObject *const_tuple_str_plain_closure_var_str_plain_empty_tuple;
42 static PyObject *const_str_plain_empty; 42 static PyObject *const_str_plain_empty;
n 43 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
44 extern PyObject *const_str_plain_print; 43 extern PyObject *const_str_plain_print;
45 static PyObject *const_int_pos_50000; 44 static PyObject *const_int_pos_50000;
46 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 45 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
47 static PyObject *const_str_plain_calledRepeatedly; 46 static PyObject *const_str_plain_calledRepeatedly;
48 static PyObject *const_str_angle_module; 47 static PyObject *const_str_angle_module;
62 61
63 /* Function to create module private constants. */ 62 /* Function to create module private constants. */
64 static void createModuleConstants( void ) 63 static void createModuleConstants( void )
65 { 64 {
66     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 ); 65     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 0 ], 9, 1 );
n 67     const_tuple_str_plain_closure_var_tuple = PyTuple_New( 1 ); n
68     const_str_plain_closure_var = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 11, 1 );
69     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_tuple, 0, const_str_plain_closure_var ); Py_INCREF( const_str_plain_closure_var );
70     const_str_plain_module_var = UNSTREAM_STRING_ASCII( &constant_bin[ 20 ], 10, 1 ); 66     const_str_plain_module_var = UNSTREAM_STRING_ASCII( &constant_bin[ 9 ], 10, 1 );
71     const_str_digest_870771c64f3015e44351e054d4d79ee7 = UNSTREAM_STRING_ASCII( &constant_bin[ 30 ], 83, 0 ); 67     const_str_digest_870771c64f3015e44351e054d4d79ee7 = UNSTREAM_STRING_ASCII( &constant_bin[ 19 ], 83, 0 );
68     const_str_plain_closure_var = UNSTREAM_STRING_ASCII( &constant_bin[ 102 ], 11, 1 );
72     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 ); 69     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 );
73     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 0, const_str_plain_closure_var ); Py_INCREF( const_str_plain_closure_var ); 70     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 0, const_str_plain_closure_var ); Py_INCREF( const_str_plain_closure_var );
74     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 113 ], 5, 1 ); 71     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 113 ], 5, 1 );
75     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 1, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 72     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 1, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
n 76     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII( &constant_bin[ 118 ], 31, 0 ); n
77     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 73     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
78     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 74     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 79     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 149 ], 3, 0 ); n 75     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 118 ], 3, 0 );
80     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 76     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 81     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 118 ], 16, 1 ); n 77     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 121 ], 16, 1 );
82     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 152 ], 8, 0 ); 78     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 137 ], 8, 0 );
83     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 160 ], 4, 1 ); 79     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 145 ], 4, 1 );
84     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 55 ], 1, 1 ); 80     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 1, 1 );
85     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 164 ], 6, 1 ); 81     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 149 ], 6, 1 );
86     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 82     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
87     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 83     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
88     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 84     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
89 85
90     constants_created = true; 86     constants_created = true;
102 #endif 98 #endif
103 99
104 // The module code objects. 100 // The module code objects.
105 static PyCodeObject *codeobj_ce8d0c7ed724e22dff7f3278af7c5ef0; 101 static PyCodeObject *codeobj_ce8d0c7ed724e22dff7f3278af7c5ef0;
106 static PyCodeObject *codeobj_8bc254249de1cf769289fa87276f5ed9; 102 static PyCodeObject *codeobj_8bc254249de1cf769289fa87276f5ed9;
n 107 static PyCodeObject *codeobj_d1c10c371d79260acaac603fa5f9b2cc; n
108 /* For use in "MainProgram.c". */ 103 /* For use in "MainProgram.c". */
109 PyCodeObject *codeobj_main = NULL; 104 PyCodeObject *codeobj_main = NULL;
110 105
111 static void createModuleCodeObjects(void) 106 static void createModuleCodeObjects(void)
112 { 107 {
113     module_filename_obj = const_str_digest_870771c64f3015e44351e054d4d79ee7; 108     module_filename_obj = const_str_digest_870771c64f3015e44351e054d4d79ee7;
114     codeobj_ce8d0c7ed724e22dff7f3278af7c5ef0 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 109     codeobj_ce8d0c7ed724e22dff7f3278af7c5ef0 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
115     codeobj_8bc254249de1cf769289fa87276f5ed9 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_closure_var_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 110     codeobj_8bc254249de1cf769289fa87276f5ed9 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_closure_var_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
n 116     codeobj_d1c10c371d79260acaac603fa5f9b2cc = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 28, const_tuple_str_plain_closure_var_tuple, 0, 0, CO_GENERATOR | CO_OPTIMIZED | CO_NEWLOCALS ); n
117 } 111 }
118 112
119 // The module function declarations. 113 // The module function declarations.
n 120 static PyObject *__main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_maker( void ); n
121  
122  
123 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 114 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 124   n
125  
126 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
127 115
128 116
129 // The module function definitions. 117 // The module function definitions.
130 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 118 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
131 { 119 {
133 #ifndef __NUITKA_NO_ASSERT__ 121 #ifndef __NUITKA_NO_ASSERT__
134     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 122     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
135 #endif 123 #endif
136 124
137     // Local variable declarations. 125     // Local variable declarations.
n 138     struct Nuitka_CellObject *var_closure_var = PyCell_EMPTY(); n
139     PyObject *var_empty = NULL; 126     PyObject *var_closure_var = NULL;
140     struct Nuitka_FrameObject *frame_8bc254249de1cf769289fa87276f5ed9; 127     struct Nuitka_FrameObject *frame_8bc254249de1cf769289fa87276f5ed9;
141     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 128     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
142     PyObject *exception_type = NULL; 129     PyObject *exception_type = NULL;
143     PyObject *exception_value = NULL; 130     PyObject *exception_value = NULL;
144     PyTracebackObject *exception_tb = NULL; 131     PyTracebackObject *exception_tb = NULL;
181             exception_tb = NULL; 168             exception_tb = NULL;
182             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 169             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
183             CHAIN_EXCEPTION( exception_value ); 170             CHAIN_EXCEPTION( exception_value );
184 171
185             exception_lineno = 25; 172             exception_lineno = 25;
n 186             type_description_1 = "co"; n 173             type_description_1 = "oN";
187             goto frame_exception_exit_1; 174             goto frame_exception_exit_1;
188         } 175         }
189 176
190         tmp_assign_source_1 = tmp_mvar_value_1; 177         tmp_assign_source_1 = tmp_mvar_value_1;
n 191         assert( PyCell_GET( var_closure_var == NULL ); n 178         assert( var_closure_var == NULL );
192         Py_INCREF( tmp_assign_source_1 ); 179         Py_INCREF( tmp_assign_source_1 );
n 193         PyCell_SET( var_closure_var, tmp_assign_source_1 ); n 180         var_closure_var = tmp_assign_source_1;
194  
195     } 181     }
196 182
197 #if 0 183 #if 0
198     RESTORE_FRAME_EXCEPTION( frame_8bc254249de1cf769289fa87276f5ed9 ); 184     RESTORE_FRAME_EXCEPTION( frame_8bc254249de1cf769289fa87276f5ed9 );
199 #endif 185 #endif
221     // Attachs locals to frame if any. 207     // Attachs locals to frame if any.
222     Nuitka_Frame_AttachLocals( 208     Nuitka_Frame_AttachLocals(
223         (struct Nuitka_FrameObject *)frame_8bc254249de1cf769289fa87276f5ed9, 209         (struct Nuitka_FrameObject *)frame_8bc254249de1cf769289fa87276f5ed9,
224         type_description_1, 210         type_description_1,
225         var_closure_var, 211         var_closure_var,
n 226         var_empty n 212         NULL
227     ); 213     );
228 214
229 215
230     // Release cached frame. 216     // Release cached frame.
231     if ( frame_8bc254249de1cf769289fa87276f5ed9 == cache_frame_8bc254249de1cf769289fa87276f5ed9 ) 217     if ( frame_8bc254249de1cf769289fa87276f5ed9 == cache_frame_8bc254249de1cf769289fa87276f5ed9 )
242     // Return the error. 228     // Return the error.
243     goto try_except_handler_1; 229     goto try_except_handler_1;
244 230
245     frame_no_exception_1:; 231     frame_no_exception_1:;
246     { 232     {
n 247         PyObject *tmp_assign_source_2; n
248         tmp_assign_source_2 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
249  
250         ((struct Nuitka_FunctionObject *)tmp_assign_source_2)->m_closure[0] = var_closure_var;
251         Py_INCREF( ((struct Nuitka_FunctionObject *)tmp_assign_source_2)->m_closure[0] );
252  
253  
254         assert( var_empty == NULL );
255         var_empty = tmp_assign_source_2;
256     }
257     {
258         PyObject *tmp_tuple_element_1; 233         PyObject *tmp_tuple_element_1;
n 259         CHECK_OBJECT( var_empty ); n
260         tmp_tuple_element_1 = var_empty; 234         tmp_tuple_element_1 = const_int_pos_1;
261         tmp_return_value = PyTuple_New( 2 ); 235         tmp_return_value = PyTuple_New( 2 );
262         Py_INCREF( tmp_tuple_element_1 ); 236         Py_INCREF( tmp_tuple_element_1 );
263         PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 ); 237         PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 );
n 264         CHECK_OBJECT( PyCell_GET( var_closure_var ); n 238         CHECK_OBJECT( var_closure_var );
265         tmp_tuple_element_1 = PyCell_GET( var_closure_var ); 239         tmp_tuple_element_1 = var_closure_var;
266         Py_INCREF( tmp_tuple_element_1 ); 240         Py_INCREF( tmp_tuple_element_1 );
267         PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 ); 241         PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 );
268         goto try_return_handler_1; 242         goto try_return_handler_1;
269     } 243     }
270     // tried codes exits in all cases 244     // tried codes exits in all cases
273     // Return handler code: 247     // Return handler code:
274     try_return_handler_1:; 248     try_return_handler_1:;
275     CHECK_OBJECT( (PyObject *)var_closure_var ); 249     CHECK_OBJECT( (PyObject *)var_closure_var );
276     Py_DECREF( var_closure_var ); 250     Py_DECREF( var_closure_var );
277     var_closure_var = NULL; 251     var_closure_var = NULL;
n 278   n
279     CHECK_OBJECT( (PyObject *)var_empty );
280     Py_DECREF( var_empty );
281     var_empty = NULL;
282 252
283     goto function_return_exit; 253     goto function_return_exit;
284     // Exception handler code: 254     // Exception handler code:
285     try_except_handler_1:; 255     try_except_handler_1:;
286     exception_keeper_type_1 = exception_type; 256     exception_keeper_type_1 = exception_type;
321    assert( had_error || !ERROR_OCCURRED() ); 291    assert( had_error || !ERROR_OCCURRED() );
322    return tmp_return_value; 292    return tmp_return_value;
323 } 293 }
324 294
325 295
n 326 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) n
327 {
328     // Preserve error status for checks
329 #ifndef __NUITKA_NO_ASSERT__
330     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
331 #endif
332  
333     // Local variable declarations.
334     PyObject *tmp_return_value = NULL;
335  
336     // Actual function body.
337     tmp_return_value = __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_maker();
338  
339     ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] = self->m_closure[0];
340     Py_INCREF( ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] );
341  
342  
343     goto function_return_exit;
344  
345     // Return statement must have exited already.
346     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
347     return NULL;
348  
349  
350 function_return_exit:
351    // Function cleanup code if any.
352  
353  
354    // Actual function exit with return value, making sure we did not make
355    // the error status worse despite non-NULL return.
356    CHECK_OBJECT( tmp_return_value );
357    assert( had_error || !ERROR_OCCURRED() );
358    return tmp_return_value;
359 }
360  
361  
362  
363 struct __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_locals {
364     char const *type_description_1;
365     PyObject *exception_type;
366     PyObject *exception_value;
367     PyTracebackObject *exception_tb;
368     int exception_lineno;
369 };
370  
371 static PyObject *__main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
372 {
373     CHECK_OBJECT( (PyObject *)generator );
374     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
375  
376     // Heap access if used.
377     struct __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_locals *generator_heap = (struct __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_locals *)generator->m_heap_storage;
378  
379     // Dispatch to yield based on return label index:
380     switch(generator->m_yield_return_index) {
381     case 1: goto yield_return_1;
382     }
383  
384     // Local variable initialization
385     static struct Nuitka_FrameObject *cache_m_frame = NULL;
386     generator_heap->type_description_1 = NULL;
387     generator_heap->exception_type = NULL;
388     generator_heap->exception_value = NULL;
389     generator_heap->exception_tb = NULL;
390     generator_heap->exception_lineno = 0;
391  
392     // Actual generator function body.
393     MAKE_OR_REUSE_FRAME( cache_m_frame, codeobj_d1c10c371d79260acaac603fa5f9b2cc, module___main__, sizeof(void *) );
394     generator->m_frame = cache_m_frame;
395  
396     // Mark the frame object as in use, ref count 1 will be up for reuse.
397     Py_INCREF( generator->m_frame );
398     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
399  
400 #if PYTHON_VERSION >= 340
401     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
402 #endif
403  
404     Py_CLEAR( generator->m_frame->m_frame.f_back );
405  
406     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
407     Py_INCREF( generator->m_frame->m_frame.f_back );
408  
409     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
410     Py_INCREF( generator->m_frame );
411  
412     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
413  
414 #if PYTHON_VERSION >= 300
415     // Accept currently existing exception as the one to publish again when we
416     // yield or yield from.
417     {
418         PyThreadState *thread_state = PyThreadState_GET();
419  
420 #if PYTHON_VERSION < 370
421         generator->m_frame->m_frame.f_exc_type = EXC_TYPE( thread_state );
422     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
423         Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
424     generator->m_frame->m_frame.f_exc_value = EXC_VALUE( thread_state );
425         Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
426     generator->m_frame->m_frame.f_exc_traceback = EXC_TRACEBACK( thread_state );
427         Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
428 #else
429         generator->m_exc_state.exc_type = EXC_TYPE( thread_state );
430         if ( generator->m_exc_state.exc_type == Py_None ) generator->m_exc_state.exc_type = NULL;
431         Py_XINCREF( generator->m_exc_state.exc_type );
432         generator->m_exc_state.exc_value = EXC_VALUE( thread_state );
433         Py_XINCREF( generator->m_exc_state.exc_value );
434         generator->m_exc_state.exc_traceback = EXC_TRACEBACK( thread_state );
435         Py_XINCREF( generator->m_exc_state.exc_traceback );
436 #endif
437     }
438  
439 #endif
440  
441     // Framed code:
442     {
443         PyObject *tmp_expression_name_1;
444         NUITKA_MAY_BE_UNUSED PyObject *tmp_yield_result_1;
445         if ( PyCell_GET( generator->m_closure[0] ) == NULL )
446         {
447  
448             generator_heap->exception_type = PyExc_NameError;
449             Py_INCREF( generator_heap->exception_type );
450             generator_heap->exception_value = PyUnicode_FromFormat( "free variable '%s' referenced before assignment in enclosing scope", "closure_var" );
451             generator_heap->exception_tb = NULL;
452             NORMALIZE_EXCEPTION( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
453             CHAIN_EXCEPTION( generator_heap->exception_value );
454  
455             generator_heap->exception_lineno = 29;
456             generator_heap->type_description_1 = "c";
457             goto frame_exception_exit_1;
458         }
459  
460         tmp_expression_name_1 = PyCell_GET( generator->m_closure[0] );
461         Py_INCREF( tmp_expression_name_1 );
462         generator->m_yield_return_index = 1;
463         return tmp_expression_name_1;
464         yield_return_1:
465         if ( yield_return_value == NULL )
466         {
467             assert( ERROR_OCCURRED() );
468  
469             FETCH_ERROR_OCCURRED( &generator_heap->exception_type, &generator_heap->exception_value, &generator_heap->exception_tb );
470  
471  
472             generator_heap->exception_lineno = 29;
473             generator_heap->type_description_1 = "c";
474             goto frame_exception_exit_1;
475         }
476         tmp_yield_result_1 = yield_return_value;
477     }
478  
479     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
480  
481 #if PYTHON_VERSION >= 370
482     Py_CLEAR( generator->m_exc_state.exc_type );
483     Py_CLEAR( generator->m_exc_state.exc_value );
484     Py_CLEAR( generator->m_exc_state.exc_traceback );
485 #elif PYTHON_VERSION >= 300
486     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
487     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
488     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
489 #endif
490  
491     // Allow re-use of the frame again.
492     Py_DECREF( generator->m_frame );
493     goto frame_no_exception_1;
494  
495     frame_exception_exit_1:;
496  
497     // If it's not an exit exception, consider and create a traceback for it.
498     if ( !EXCEPTION_MATCH_GENERATOR( generator_heap->exception_type ) )
499     {
500         if ( generator_heap->exception_tb == NULL )
501         {
502             generator_heap->exception_tb = MAKE_TRACEBACK( generator->m_frame, generator_heap->exception_lineno );
503         }
504         else if ( generator_heap->exception_tb->tb_frame != &generator->m_frame->m_frame )
505         {
506             generator_heap->exception_tb = ADD_TRACEBACK( generator_heap->exception_tb, generator->m_frame, generator_heap->exception_lineno );
507         }
508  
509         Nuitka_Frame_AttachLocals(
510             (struct Nuitka_FrameObject *)generator->m_frame,
511             generator_heap->type_description_1,
512             generator->m_closure[0]
513         );
514  
515  
516         // Release cached frame.
517         if ( generator->m_frame == cache_m_frame )
518         {
519             Py_DECREF( generator->m_frame );
520         }
521         cache_m_frame = NULL;
522  
523         assertFrameObject( generator->m_frame );
524     }
525  
526 #if PYTHON_VERSION >= 370
527     Py_CLEAR( generator->m_exc_state.exc_type );
528     Py_CLEAR( generator->m_exc_state.exc_value );
529     Py_CLEAR( generator->m_exc_state.exc_traceback );
530 #elif PYTHON_VERSION >= 300
531     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
532     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
533     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
534 #endif
535  
536     Py_DECREF( generator->m_frame );
537  
538     // Return the error.
539     goto function_exception_exit;
540  
541     frame_no_exception_1:;
542  
543  
544     return NULL;
545  
546     function_exception_exit:
547     assert( generator_heap->exception_type );
548     RESTORE_ERROR_OCCURRED( generator_heap->exception_type, generator_heap->exception_value, generator_heap->exception_tb );
549  
550     return NULL;
551  
552 }
553  
554 static PyObject *__main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_maker( void )
555 {
556     return Nuitka_Generator_New(
557         __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context,
558         module___main__,
559         const_str_plain_empty,
560 #if PYTHON_VERSION >= 350
561         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
562 #endif
563         codeobj_d1c10c371d79260acaac603fa5f9b2cc,
564         1,
565         sizeof(struct __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_locals)
566     );
567 }
568  
569  
570 296
571 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 297 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )
572 { 298 {
573     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 299     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
574         impl___main__$$$function_1_calledRepeatedly, 300         impl___main__$$$function_1_calledRepeatedly,
583         NULL, 309         NULL,
584 #endif 310 #endif
585         module___main__, 311         module___main__,
586         NULL, 312         NULL,
587         0 313         0
t 588     ); t
589  
590     return (PyObject *)result;
591 }
592  
593  
594  
595 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
596 {
597     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
598         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
599         const_str_plain_empty,
600 #if PYTHON_VERSION >= 300
601         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
602 #endif
603         codeobj_d1c10c371d79260acaac603fa5f9b2cc,
604         NULL,
605 #if PYTHON_VERSION >= 300
606         NULL,
607         NULL,
608 #endif
609         module___main__,
610         NULL,
611         1
612     ); 314     );
613 315
614     return (PyObject *)result; 316     return (PyObject *)result;
615 } 317 }
616 318