Construct FunctionCreationGeneratorClosure

Performance Diagrams

Construct FunctionCreationGeneratorClosure 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)4496823973.61538461538461275.4744343090871CPython 2.748601721196.30769230769232257.0Nuitka (historic)12653041319.0000000000001439.7810147837231Nuitka (master)12652913441.69230769230774439.7816655995498Nuitka (develop)12702453564.3846153846155439.52977953662935Nuitka (factory)Construct FunctionCreationGeneratorClosureTicks Construct FunctionCreationGeneratorClosure 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)5639723473.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)15804002319.0000000000001434.8670943057516Nuitka (master)15811931441.69230769230774434.83235185925827Nuitka (develop)15860429564.3846153846155434.6198484956522Nuitka (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


for x in xrange(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


for x in xrange(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 for x in xrange(50000): 38 for x in xrange(50000):

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 module constants used, if any. */ 33 /* The module constants used, if any. */
34 static PyObject *const_str_plain___package__; 34 static PyObject *const_str_plain___package__;
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 extern PyObject *const_int_pos_1; 36 extern PyObject *const_int_pos_1;
38 extern PyObject *const_dict_empty; 37 extern PyObject *const_dict_empty;
39 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
40 static PyObject *const_str_plain_closure_var; 39 static PyObject *const_str_plain_closure_var;
41 extern PyObject *const_int_0; 40 extern PyObject *const_int_0;
42 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;
43 static PyObject *const_xrange_0_50000; 42 static PyObject *const_xrange_0_50000;
44 static PyObject *const_str_plain_empty; 43 static PyObject *const_str_plain_empty;
45 extern PyObject *const_str_plain_print; 44 extern PyObject *const_str_plain_print;
n 46 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
47 static PyObject *const_int_pos_50000; 45 static PyObject *const_int_pos_50000;
48 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 46 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
49 static PyObject *const_str_plain_calledRepeatedly; 47 static PyObject *const_str_plain_calledRepeatedly;
50 static PyObject *const_str_angle_module; 48 static PyObject *const_str_angle_module;
51 static PyObject *const_str_plain_x; 49 static PyObject *const_str_plain_x;
61 static bool constants_created = false; 59 static bool constants_created = false;
62 60
63 static void createModuleConstants( void ) 61 static void createModuleConstants( void )
64 { 62 {
65     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 ); 63     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 );
n 66     const_tuple_str_plain_closure_var_tuple = PyTuple_New( 1 ); n 64     const_str_plain_module_var = UNSTREAM_STRING( &constant_bin[ 11 ], 10, 1 );
67     const_str_plain_closure_var = UNSTREAM_STRING( &constant_bin[ 11 ], 11, 1 ); 65     const_str_plain_closure_var = UNSTREAM_STRING( &constant_bin[ 21 ], 11, 1 );
68     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_tuple, 0, const_str_plain_closure_var ); Py_INCREF( const_str_plain_closure_var );
69     const_str_plain_module_var = UNSTREAM_STRING( &constant_bin[ 22 ], 10, 1 );
70     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 ); 66     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 );
71     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 ); 67     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 );
72     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 32 ], 5, 1 ); 68     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 32 ], 5, 1 );
73     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 1, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 69     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 1, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
74     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 70     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
75     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 71     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
n 76     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 37 ], 31, 0 ); n
77     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 72     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 78     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 68 ], 3, 0 ); n 73     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 37 ], 3, 0 );
79     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 74     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 80     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 37 ], 16, 1 ); n 75     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 40 ], 16, 1 );
81     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 71 ], 8, 0 ); 76     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 56 ], 8, 0 );
82     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 79 ], 1, 1 ); 77     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 64 ], 1, 1 );
83     const_str_digest_f8c9e85d88d3751349ab7be0bf720c65 = UNSTREAM_STRING( &constant_bin[ 80 ], 90, 0 ); 78     const_str_digest_f8c9e85d88d3751349ab7be0bf720c65 = UNSTREAM_STRING( &constant_bin[ 65 ], 90, 0 );
84 79
85     constants_created = true; 80     constants_created = true;
86 } 81 }
87 82
88 #ifndef __NUITKA_NO_ASSERT__ 83 #ifndef __NUITKA_NO_ASSERT__
96 #endif 91 #endif
97 92
98 // The module code objects. 93 // The module code objects.
99 static PyCodeObject *codeobj_9d85e8dde62538b11a905d6244c75562; 94 static PyCodeObject *codeobj_9d85e8dde62538b11a905d6244c75562;
100 static PyCodeObject *codeobj_42bad1fee025115d4ef1654e006c14c9; 95 static PyCodeObject *codeobj_42bad1fee025115d4ef1654e006c14c9;
n 101 static PyCodeObject *codeobj_5ff1f504842b1f666b67b3589d40bd92; n
102 /* For use in "MainProgram.c". */ 96 /* For use in "MainProgram.c". */
103 PyCodeObject *codeobj_main = NULL; 97 PyCodeObject *codeobj_main = NULL;
104 98
105 static void createModuleCodeObjects(void) 99 static void createModuleCodeObjects(void)
106 { 100 {
107     module_filename_obj = const_str_digest_f8c9e85d88d3751349ab7be0bf720c65; 101     module_filename_obj = const_str_digest_f8c9e85d88d3751349ab7be0bf720c65;
108     codeobj_9d85e8dde62538b11a905d6244c75562 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 102     codeobj_9d85e8dde62538b11a905d6244c75562 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
109     codeobj_main = codeobj_9d85e8dde62538b11a905d6244c75562; 103     codeobj_main = codeobj_9d85e8dde62538b11a905d6244c75562;
110     codeobj_42bad1fee025115d4ef1654e006c14c9 = 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 ); 104     codeobj_42bad1fee025115d4ef1654e006c14c9 = 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 111     codeobj_5ff1f504842b1f666b67b3589d40bd92 = 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
112 } 105 }
113 106
114 // The module function declarations. 107 // The module function declarations.
n 115 static void __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator ); n
116  
117  
118 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 108 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 119   n
120  
121 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_CellObject *closure_closure_var );
122 109
123 110
124 // The module function definitions. 111 // The module function definitions.
125 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 112 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
126 { 113 {
128 #ifndef __NUITKA_NO_ASSERT__ 115 #ifndef __NUITKA_NO_ASSERT__
129     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 116     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
130 #endif 117 #endif
131 118
132     // Local variable declarations. 119     // Local variable declarations.
n 133     struct Nuitka_CellObject *var_closure_var = PyCell_EMPTY(); n
134     PyObject *var_empty = NULL; 120     PyObject *var_closure_var = NULL;
135     PyObject *exception_type = NULL, *exception_value = NULL; 121     PyObject *exception_type = NULL, *exception_value = NULL;
136     PyTracebackObject *exception_tb = NULL; 122     PyTracebackObject *exception_tb = NULL;
137     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 123     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
138     PyObject *exception_keeper_type_1; 124     PyObject *exception_keeper_type_1;
139     PyObject *exception_keeper_value_1; 125     PyObject *exception_keeper_value_1;
140     PyTracebackObject *exception_keeper_tb_1; 126     PyTracebackObject *exception_keeper_tb_1;
141     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 127     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
142     PyObject *tmp_assign_source_1; 128     PyObject *tmp_assign_source_1;
n 143     PyObject *tmp_assign_source_2; n
144     PyObject *tmp_return_value; 129     PyObject *tmp_return_value;
145     PyObject *tmp_tuple_element_1; 130     PyObject *tmp_tuple_element_1;
146     static struct Nuitka_FrameObject *cache_frame_function = NULL; 131     static struct Nuitka_FrameObject *cache_frame_function = NULL;
147 132
148     struct Nuitka_FrameObject *frame_function; 133     struct Nuitka_FrameObject *frame_function;
150     char const *type_description; 135     char const *type_description;
151     tmp_return_value = NULL; 136     tmp_return_value = NULL;
152 137
153     // Actual function code. 138     // Actual function code.
154     // Tried code: 139     // Tried code:
n 155     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_42bad1fee025115d4ef1654e006c14c9, module___main__, sizeof(struct Nuitka_CellObject *)+sizeof(PyObject *) ); n 140     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_42bad1fee025115d4ef1654e006c14c9, module___main__, sizeof(void *)+sizeof(PyObject *) );
156     frame_function = cache_frame_function; 141     frame_function = cache_frame_function;
157 142
158     // Push the new frame as the currently active one. 143     // Push the new frame as the currently active one.
159     pushFrameStack( frame_function ); 144     pushFrameStack( frame_function );
160 145
178         exception_tb = NULL; 163         exception_tb = NULL;
179         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 164         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
180         CHAIN_EXCEPTION( exception_value ); 165         CHAIN_EXCEPTION( exception_value );
181 166
182         exception_lineno = 25; 167         exception_lineno = 25;
n 183         type_description = "co"; n 168         type_description = "oN";
184         goto frame_exception_exit_1; 169         goto frame_exception_exit_1;
185     } 170     }
186 171
n 187     { n 172     assert( var_closure_var == NULL );
188         PyObject *old = PyCell_GET( var_closure_var );
189         PyCell_SET( var_closure_var, tmp_assign_source_1 );
190         Py_INCREF( tmp_assign_source_1 ); 173     Py_INCREF( tmp_assign_source_1 );
191         Py_XDECREF( old ); 174     var_closure_var = tmp_assign_source_1;
175  
176  
177 #if 0
178     RESTORE_FRAME_EXCEPTION( frame_function );
179 #endif
180  
181     // Put the previous frame back on top.
182     popFrameStack();
183  
184     goto frame_no_exception_1;
185  
186     frame_exception_exit_1:;
187  
188 #if 0
189     RESTORE_FRAME_EXCEPTION( frame_function );
190 #endif
191  
192     if ( exception_tb == NULL )
192     } 193     {
194         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
195     }
196     else if ( exception_tb->tb_frame != &frame_function->m_frame )
197     {
198         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
199     }
193 200
n 194     tmp_assign_source_2 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( var_closure_var ); n 201     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,var_closure_var, NULL );
195     assert( var_empty == NULL ); 202  
196     var_empty = tmp_assign_source_2; 203     // Release cached frame.
204     if ( frame_function == cache_frame_function )
205     {
206         Py_DECREF( frame_function );
207     }
208     cache_frame_function = NULL;
209  
210     assertFrameObject( frame_function );
211  
212  
213     // Put the previous frame back on top.
214     popFrameStack();
215  
216     // Return the error.
217     goto try_except_handler_1;
218  
219     frame_no_exception_1:;
197 220
198     tmp_return_value = PyTuple_New( 2 ); 221     tmp_return_value = PyTuple_New( 2 );
n 199     tmp_tuple_element_1 = var_empty; n 222     tmp_tuple_element_1 = const_int_pos_1;
200  
201     Py_INCREF( tmp_tuple_element_1 ); 223     Py_INCREF( tmp_tuple_element_1 );
202     PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 ); 224     PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 );
n 203     tmp_tuple_element_1 = PyCell_GET( var_closure_var ); n 225     tmp_tuple_element_1 = var_closure_var;
204  
205     if ( tmp_tuple_element_1 == NULL )
206     {
207         Py_DECREF( tmp_return_value );
208         exception_type = PyExc_UnboundLocalError;
209         Py_INCREF( exception_type );
210         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "closure_var" );
211         exception_tb = NULL;
212         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
213         CHAIN_EXCEPTION( exception_value );
214  
215         exception_lineno = 35;
216         type_description = "co";
217         goto frame_exception_exit_1;
218     }
219 226
220     Py_INCREF( tmp_tuple_element_1 ); 227     Py_INCREF( tmp_tuple_element_1 );
221     PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 ); 228     PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 );
n 222     goto frame_return_exit_1; n
223  
224 #if 0
225     RESTORE_FRAME_EXCEPTION( frame_function );
226 #endif
227  
228     // Put the previous frame back on top.
229     popFrameStack();
230  
231     goto frame_no_exception_1;
232  
233     frame_return_exit_1:;
234 #if 0
235     RESTORE_FRAME_EXCEPTION( frame_function );
236 #endif
237  
238     // Put the previous frame back on top.
239     popFrameStack();
240  
241     goto try_return_handler_1; 229     goto try_return_handler_1;
n 242   n
243     frame_exception_exit_1:;
244  
245 #if 0
246     RESTORE_FRAME_EXCEPTION( frame_function );
247 #endif
248  
249     if ( exception_tb == NULL )
250     {
251         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
252     }
253     else if ( exception_tb->tb_frame != &frame_function->m_frame )
254     {
255         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
256     }
257  
258     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,var_closure_var, var_empty );
259  
260     // Release cached frame.
261     if ( frame_function == cache_frame_function )
262     {
263         Py_DECREF( frame_function );
264     }
265     cache_frame_function = NULL;
266  
267     assertFrameObject( frame_function );
268  
269  
270     // Put the previous frame back on top.
271     popFrameStack();
272  
273     // Return the error.
274     goto try_except_handler_1;
275  
276     frame_no_exception_1:;
277  
278     // tried codes exits in all cases 230     // tried codes exits in all cases
279     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 231     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
280     return NULL; 232     return NULL;
281     // Return handler code: 233     // Return handler code:
282     try_return_handler_1:; 234     try_return_handler_1:;
283     CHECK_OBJECT( (PyObject *)var_closure_var ); 235     CHECK_OBJECT( (PyObject *)var_closure_var );
284     Py_DECREF( var_closure_var ); 236     Py_DECREF( var_closure_var );
285     var_closure_var = NULL; 237     var_closure_var = NULL;
n 286   n
287     Py_XDECREF( var_empty );
288     var_empty = NULL;
289 238
290     goto function_return_exit; 239     goto function_return_exit;
291     // Exception handler code: 240     // Exception handler code:
292     try_except_handler_1:; 241     try_except_handler_1:;
293     exception_keeper_type_1 = exception_type; 242     exception_keeper_type_1 = exception_type;
297     exception_type = NULL; 246     exception_type = NULL;
298     exception_value = NULL; 247     exception_value = NULL;
299     exception_tb = NULL; 248     exception_tb = NULL;
300     exception_lineno = -1; 249     exception_lineno = -1;
301 250
n 302     CHECK_OBJECT( (PyObject *)var_closure_var ); n
303     Py_DECREF( var_closure_var );
304     var_closure_var = NULL;
305  
306     Py_XDECREF( var_empty );
307     var_empty = NULL;
308  
309     // Re-raise. 251     // Re-raise.
310     exception_type = exception_keeper_type_1; 252     exception_type = exception_keeper_type_1;
311     exception_value = exception_keeper_value_1; 253     exception_value = exception_keeper_value_1;
312     exception_tb = exception_keeper_tb_1; 254     exception_tb = exception_keeper_tb_1;
313     exception_lineno = exception_keeper_lineno_1; 255     exception_lineno = exception_keeper_lineno_1;
328 270
329     CHECK_OBJECT( tmp_return_value ); 271     CHECK_OBJECT( tmp_return_value );
330     assert( had_error || !ERROR_OCCURRED() ); 272     assert( had_error || !ERROR_OCCURRED() );
331     return tmp_return_value; 273     return tmp_return_value;
332 274
n 333 } n
334  
335  
336 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
337 {
338     // Preserve error status for checks
339 #ifndef __NUITKA_NO_ASSERT__
340     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
341 #endif
342  
343     // Local variable declarations.
344     PyObject *tmp_return_value;
345     tmp_return_value = NULL;
346  
347     // Actual function code.
348     tmp_return_value = Nuitka_Generator_New(
349         __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context,
350         module___main__,
351         self->m_name,
352 #if PYTHON_VERSION >= 350
353         self->m_qualname,
354 #endif
355         codeobj_5ff1f504842b1f666b67b3589d40bd92,
356         1
357     );
358  
359     ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] = self->m_closure[0];
360     Py_INCREF( ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] );
361  
362  
363     goto function_return_exit;
364  
365     // Return statement must have exited already.
366     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
367     return NULL;
368  
369     function_return_exit:
370  
371     CHECK_OBJECT( tmp_return_value );
372     assert( had_error || !ERROR_OCCURRED() );
373     return tmp_return_value;
374  
375 }
376  
377  
378  
379 static void __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator )
380 {
381     CHECK_OBJECT( (PyObject *)generator );
382     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
383  
384     // Local variable initialization
385     PyObject *exception_type = NULL, *exception_value = NULL;
386     PyTracebackObject *exception_tb = NULL;
387     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
388     PyObject *tmp_expression_name_1;
389     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
390     static struct Nuitka_FrameObject *cache_frame_generator = NULL;
391  
392     char const *type_description;
393  
394     // Actual function code.
395     MAKE_OR_REUSE_FRAME( cache_frame_generator, codeobj_5ff1f504842b1f666b67b3589d40bd92, module___main__, sizeof(struct Nuitka_CellObject *) );
396     generator->m_frame = cache_frame_generator;
397  
398     // Mark the frame object as in use, ref count 1 will be up for reuse.
399     Py_INCREF( generator->m_frame );
400     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
401  
402 #if PYTHON_VERSION >= 340
403     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
404 #endif
405  
406     Py_CLEAR( generator->m_frame->m_frame.f_back );
407  
408     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
409     Py_INCREF( generator->m_frame->m_frame.f_back );
410  
411     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
412     Py_INCREF( generator->m_frame );
413  
414     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
415  
416 #if PYTHON_VERSION >= 300
417     // Accept currently existing exception as the one to publish again when we
418     // yield or yield from.
419  
420     PyThreadState *thread_state = PyThreadState_GET();
421  
422     generator->m_frame->m_frame.f_exc_type = thread_state->exc_type;
423     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
424     Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
425     generator->m_frame->m_frame.f_exc_value = thread_state->exc_value;
426     Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
427     generator->m_frame->m_frame.f_exc_traceback = thread_state->exc_traceback;
428     Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
429 #endif
430  
431     // Framed code:
432     tmp_expression_name_1 = PyCell_GET( generator->m_closure[0] );
433  
434     if ( tmp_expression_name_1 == NULL )
435     {
436  
437         exception_type = PyExc_NameError;
438         Py_INCREF( exception_type );
439         exception_value = PyUnicode_FromFormat( "free variable '%s' referenced before assignment in enclosing scope", "closure_var" );
440         exception_tb = NULL;
441         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
442         CHAIN_EXCEPTION( exception_value );
443  
444         exception_lineno = 29;
445         type_description = "c";
446         goto frame_exception_exit_1;
447     }
448  
449     tmp_unused = GENERATOR_YIELD( generator, INCREASE_REFCOUNT( tmp_expression_name_1 ) );
450     if ( tmp_unused == NULL )
451     {
452         assert( ERROR_OCCURRED() );
453  
454         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
455  
456  
457         exception_lineno = 29;
458         type_description = "c";
459         goto frame_exception_exit_1;
460     }
461  
462     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
463  
464 #if PYTHON_VERSION >= 300
465     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
466     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
467     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
468 #endif
469  
470     // Allow re-use of the frame again.
471     Py_DECREF( generator->m_frame );
472     goto frame_no_exception_1;
473  
474     frame_exception_exit_1:;
475  
476     // If it's not an exit exception, consider and create a traceback for it.
477     if ( !EXCEPTION_MATCH_GENERATOR( exception_type ) )
478     {
479         if ( exception_tb == NULL )
480         {
481             exception_tb = MAKE_TRACEBACK( generator->m_frame, exception_lineno );
482         }
483         else if ( exception_tb->tb_frame != &generator->m_frame->m_frame )
484         {
485             exception_tb = ADD_TRACEBACK( exception_tb, generator->m_frame, exception_lineno );
486         }
487  
488         Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)generator->m_frame, type_description ,generator->m_closure[0] );
489  
490         // Release cached frame.
491         if ( generator->m_frame == cache_frame_generator )
492         {
493             Py_DECREF( generator->m_frame );
494         }
495         cache_frame_generator = NULL;
496  
497         assertFrameObject( generator->m_frame );
498     }
499  
500 #if PYTHON_VERSION >= 300
501     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
502     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
503     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
504 #endif
505  
506     Py_DECREF( generator->m_frame );
507     // Return the error.
508     goto function_exception_exit;
509  
510     frame_no_exception_1:;
511  
512  
513     generator->m_yielded = NULL;
514     return;
515  
516     function_exception_exit:
517     assert( exception_type );
518     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
519     generator->m_yielded = NULL;
520     return;
521 } 275 }
522 276
523 277
524 278
525 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 279 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )
539         module___main__, 293         module___main__,
540         Py_None, 294         Py_None,
541         0 295         0
542     ); 296     );
543 297
t 544   t
545     return (PyObject *)result;
546 }
547  
548  
549  
550 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_CellObject *closure_closure_var )
551 {
552     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
553         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
554         const_str_plain_empty,
555 #if PYTHON_VERSION >= 330
556         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
557 #endif
558         codeobj_5ff1f504842b1f666b67b3589d40bd92,
559         NULL,
560 #if PYTHON_VERSION >= 300
561         NULL,
562         const_dict_empty,
563 #endif
564         module___main__,
565         Py_None,
566         1
567     );
568  
569 result->m_closure[0] = closure_closure_var;
570 Py_INCREF( result->m_closure[0] );
571 298
572     return (PyObject *)result; 299     return (PyObject *)result;
573 } 300 }
574 301
575 302