Construct FunctionCreationGeneratorClosure

Performance Diagrams

Construct FunctionCreationGeneratorClosure 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)5075031488.95192307692307257.0CPython 2.713001479242.31730769230768440.808082050639Nuitka (master)13001623395.6826923076923440.8073808802899Nuitka (develop)13001455549.0480769230769440.8081989123639Nuitka (factory)Construct FunctionCreationGeneratorClosureTicks Construct FunctionCreationGeneratorClosure 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)5659295588.95192307692307257.0CPython 3.516253581242.31730769230768433.1434779497527Nuitka (master)16253257395.6826923076923433.14489270861475Nuitka (develop)16253331549.0480769230769433.14456958467713Nuitka (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
33 /* The module constants used, if any. */ 33 /* The module constants used, if any. */
34 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
35 static PyObject *const_str_plain___package__; 35 static PyObject *const_str_plain___package__;
36 static PyObject *const_str_digest_2b92970182462078cb15ee48c5fe2761; 36 static PyObject *const_str_digest_2b92970182462078cb15ee48c5fe2761;
37 static PyObject *const_str_plain___spec__; 37 static PyObject *const_str_plain___spec__;
n 38 static PyObject *const_tuple_str_plain_closure_var_tuple; n
39 static PyObject *const_str_plain_module_var; 38 static PyObject *const_str_plain_module_var;
n n 39 extern PyObject *const_int_pos_1;
40 extern PyObject *const_dict_empty; 40 extern PyObject *const_dict_empty;
41 extern PyObject *const_str_plain___file__; 41 extern PyObject *const_str_plain___file__;
42 static PyObject *const_str_plain_closure_var; 42 static PyObject *const_str_plain_closure_var;
43 extern PyObject *const_int_0; 43 extern PyObject *const_int_0;
44 static PyObject *const_tuple_str_plain_closure_var_str_plain_empty_tuple; 44 static PyObject *const_tuple_str_plain_closure_var_str_plain_empty_tuple;
45 static PyObject *const_str_plain_empty; 45 static PyObject *const_str_plain_empty;
46 extern PyObject *const_str_plain_print; 46 extern PyObject *const_str_plain_print;
n 47 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
48 static PyObject *const_int_pos_50000; 47 static PyObject *const_int_pos_50000;
49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 48 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
50 static PyObject *const_str_plain_calledRepeatedly; 49 static PyObject *const_str_plain_calledRepeatedly;
51 static PyObject *const_str_angle_module; 50 static PyObject *const_str_angle_module;
52 static PyObject *const_str_plain_x; 51 static PyObject *const_str_plain_x;
66 { 65 {
67     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 ); 66     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 );
68     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 9 ], 11, 1 ); 67     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 9 ], 11, 1 );
69     const_str_digest_2b92970182462078cb15ee48c5fe2761 = UNSTREAM_STRING( &constant_bin[ 20 ], 90, 0 ); 68     const_str_digest_2b92970182462078cb15ee48c5fe2761 = UNSTREAM_STRING( &constant_bin[ 20 ], 90, 0 );
70     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 110 ], 8, 1 ); 69     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 110 ], 8, 1 );
n 71     const_tuple_str_plain_closure_var_tuple = PyTuple_New( 1 ); n 70     const_str_plain_module_var = UNSTREAM_STRING( &constant_bin[ 118 ], 10, 1 );
72     const_str_plain_closure_var = UNSTREAM_STRING( &constant_bin[ 118 ], 11, 1 ); 71     const_str_plain_closure_var = UNSTREAM_STRING( &constant_bin[ 128 ], 11, 1 );
73     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_tuple, 0, const_str_plain_closure_var ); Py_INCREF( const_str_plain_closure_var );
74     const_str_plain_module_var = UNSTREAM_STRING( &constant_bin[ 129 ], 10, 1 );
75     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 ); 72     const_tuple_str_plain_closure_var_str_plain_empty_tuple = PyTuple_New( 2 );
76     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 ); 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 );
77     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 139 ], 5, 1 ); 74     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 139 ], 5, 1 );
78     PyTuple_SET_ITEM( const_tuple_str_plain_closure_var_str_plain_empty_tuple, 1, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 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 );
n 79     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 144 ], 31, 0 ); n
80     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 76     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
81     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 77     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 82     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 175 ], 3, 0 ); n 78     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 144 ], 3, 0 );
83     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 79     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 84     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 144 ], 16, 1 ); n 80     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 147 ], 16, 1 );
85     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 178 ], 8, 0 ); 81     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 163 ], 8, 0 );
86     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 45 ], 1, 1 ); 82     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 45 ], 1, 1 );
n 87     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 186 ], 6, 1 ); n 83     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 171 ], 6, 1 );
88     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 84     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
89     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 85     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
90     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 86     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
91 87
92     constants_created = true; 88     constants_created = true;
103 #endif 99 #endif
104 100
105 // The module code objects. 101 // The module code objects.
106 static PyCodeObject *codeobj_a016c0b98e297d0f28c6fe3acc67ea52; 102 static PyCodeObject *codeobj_a016c0b98e297d0f28c6fe3acc67ea52;
107 static PyCodeObject *codeobj_a9051fa3c304b92aa509e087f797534c; 103 static PyCodeObject *codeobj_a9051fa3c304b92aa509e087f797534c;
n 108 static PyCodeObject *codeobj_3db200e92a9fdb0e0fce14a9bc2a5b48; n
109 /* For use in "MainProgram.c". */ 104 /* For use in "MainProgram.c". */
110 PyCodeObject *codeobj_main = NULL; 105 PyCodeObject *codeobj_main = NULL;
111 106
112 static void createModuleCodeObjects(void) 107 static void createModuleCodeObjects(void)
113 { 108 {
114     module_filename_obj = const_str_digest_2b92970182462078cb15ee48c5fe2761; 109     module_filename_obj = const_str_digest_2b92970182462078cb15ee48c5fe2761;
115     codeobj_a016c0b98e297d0f28c6fe3acc67ea52 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 110     codeobj_a016c0b98e297d0f28c6fe3acc67ea52 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
116     codeobj_main = codeobj_a016c0b98e297d0f28c6fe3acc67ea52; 111     codeobj_main = codeobj_a016c0b98e297d0f28c6fe3acc67ea52;
117     codeobj_a9051fa3c304b92aa509e087f797534c = 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 ); 112     codeobj_a9051fa3c304b92aa509e087f797534c = 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 118     codeobj_3db200e92a9fdb0e0fce14a9bc2a5b48 = 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
119 } 113 }
120 114
121 // The module function declarations. 115 // The module function declarations.
n 122 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO n
123 static PyObject *__main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value );
124 #else
125 static void __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator );
126 #endif
127  
128  
129 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 116 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 130   n
131  
132 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_CellObject *closure_closure_var );
133 117
134 118
135 // The module function definitions. 119 // The module function definitions.
136 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 120 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
137 { 121 {
139 #ifndef __NUITKA_NO_ASSERT__ 123 #ifndef __NUITKA_NO_ASSERT__
140     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 124     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
141 #endif 125 #endif
142 126
143     // Local variable declarations. 127     // Local variable declarations.
n 144     struct Nuitka_CellObject *var_closure_var = PyCell_EMPTY(); n
145     PyObject *var_empty = NULL; 128     PyObject *var_closure_var = NULL;
146     PyObject *exception_type = NULL; 129     PyObject *exception_type = NULL;
147     PyObject *exception_value = NULL; 130     PyObject *exception_value = NULL;
148     PyTracebackObject *exception_tb = NULL; 131     PyTracebackObject *exception_tb = NULL;
149     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 132     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
150     PyObject *exception_keeper_type_1; 133     PyObject *exception_keeper_type_1;
151     PyObject *exception_keeper_value_1; 134     PyObject *exception_keeper_value_1;
152     PyTracebackObject *exception_keeper_tb_1; 135     PyTracebackObject *exception_keeper_tb_1;
153     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 136     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
154     PyObject *tmp_assign_source_1; 137     PyObject *tmp_assign_source_1;
n 155     PyObject *tmp_assign_source_2; n
156     PyObject *tmp_return_value; 138     PyObject *tmp_return_value;
157     PyObject *tmp_tuple_element_1; 139     PyObject *tmp_tuple_element_1;
158     static struct Nuitka_FrameObject *cache_frame_a9051fa3c304b92aa509e087f797534c = NULL; 140     static struct Nuitka_FrameObject *cache_frame_a9051fa3c304b92aa509e087f797534c = NULL;
159 141
160     struct Nuitka_FrameObject *frame_a9051fa3c304b92aa509e087f797534c; 142     struct Nuitka_FrameObject *frame_a9051fa3c304b92aa509e087f797534c;
190         exception_tb = NULL; 172         exception_tb = NULL;
191         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 173         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
192         CHAIN_EXCEPTION( exception_value ); 174         CHAIN_EXCEPTION( exception_value );
193 175
194         exception_lineno = 25; 176         exception_lineno = 25;
n 195         type_description_1 = "co"; n 177         type_description_1 = "oN";
196         goto frame_exception_exit_1; 178         goto frame_exception_exit_1;
197     } 179     }
198 180
n 199     { n 181     assert( var_closure_var == NULL );
200         PyObject *old = PyCell_GET( var_closure_var );
201         PyCell_SET( var_closure_var, tmp_assign_source_1 );
202         Py_INCREF( tmp_assign_source_1 ); 182     Py_INCREF( tmp_assign_source_1 );
203         Py_XDECREF( old );
204     }
205  
206     tmp_assign_source_2 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( var_closure_var );
207     assert( var_empty == NULL );
208     var_empty = tmp_assign_source_2; 183     var_closure_var = tmp_assign_source_1;
209 184
n 210     tmp_return_value = PyTuple_New( 2 ); n
211     tmp_tuple_element_1 = var_empty;
212  
213     CHECK_OBJECT( tmp_tuple_element_1 );
214     Py_INCREF( tmp_tuple_element_1 );
215     PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 );
216     if ( var_closure_var == NULL )
217     {
218         tmp_tuple_element_1 = NULL;
219     }
220     else
221     {
222         tmp_tuple_element_1 = PyCell_GET( var_closure_var );
223     }
224  
225     if ( tmp_tuple_element_1 == NULL )
226     {
227         Py_DECREF( tmp_return_value );
228         exception_type = PyExc_UnboundLocalError;
229         Py_INCREF( exception_type );
230         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "closure_var" );
231         exception_tb = NULL;
232         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
233         CHAIN_EXCEPTION( exception_value );
234  
235         exception_lineno = 35;
236         type_description_1 = "co";
237         goto frame_exception_exit_1;
238     }
239  
240     Py_INCREF( tmp_tuple_element_1 );
241     PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 );
242     goto frame_return_exit_1;
243 185
244 #if 0 186 #if 0
245     RESTORE_FRAME_EXCEPTION( frame_a9051fa3c304b92aa509e087f797534c ); 187     RESTORE_FRAME_EXCEPTION( frame_a9051fa3c304b92aa509e087f797534c );
246 #endif 188 #endif
247 189
248     // Put the previous frame back on top. 190     // Put the previous frame back on top.
249     popFrameStack(); 191     popFrameStack();
250 192
251     goto frame_no_exception_1; 193     goto frame_no_exception_1;
n 252   n
253     frame_return_exit_1:;
254 #if 0
255     RESTORE_FRAME_EXCEPTION( frame_a9051fa3c304b92aa509e087f797534c );
256 #endif
257  
258     // Put the previous frame back on top.
259     popFrameStack();
260  
261     goto try_return_handler_1;
262 194
263     frame_exception_exit_1:; 195     frame_exception_exit_1:;
264 196
265 #if 0 197 #if 0
266     RESTORE_FRAME_EXCEPTION( frame_a9051fa3c304b92aa509e087f797534c ); 198     RESTORE_FRAME_EXCEPTION( frame_a9051fa3c304b92aa509e087f797534c );
278     // Attachs locals to frame if any. 210     // Attachs locals to frame if any.
279     Nuitka_Frame_AttachLocals( 211     Nuitka_Frame_AttachLocals(
280         (struct Nuitka_FrameObject *)frame_a9051fa3c304b92aa509e087f797534c, 212         (struct Nuitka_FrameObject *)frame_a9051fa3c304b92aa509e087f797534c,
281         type_description_1, 213         type_description_1,
282         var_closure_var, 214         var_closure_var,
n 283         var_empty n 215         NULL
284     ); 216     );
285 217
286 218
287     // Release cached frame. 219     // Release cached frame.
288     if ( frame_a9051fa3c304b92aa509e087f797534c == cache_frame_a9051fa3c304b92aa509e087f797534c ) 220     if ( frame_a9051fa3c304b92aa509e087f797534c == cache_frame_a9051fa3c304b92aa509e087f797534c )
299     // Return the error. 231     // Return the error.
300     goto try_except_handler_1; 232     goto try_except_handler_1;
301 233
302     frame_no_exception_1:; 234     frame_no_exception_1:;
303 235
n n 236     tmp_return_value = PyTuple_New( 2 );
237     tmp_tuple_element_1 = const_int_pos_1;
238     Py_INCREF( tmp_tuple_element_1 );
239     PyTuple_SET_ITEM( tmp_return_value, 0, tmp_tuple_element_1 );
240     tmp_tuple_element_1 = var_closure_var;
241  
242     CHECK_OBJECT( tmp_tuple_element_1 );
243     Py_INCREF( tmp_tuple_element_1 );
244     PyTuple_SET_ITEM( tmp_return_value, 1, tmp_tuple_element_1 );
245     goto try_return_handler_1;
304     // tried codes exits in all cases 246     // tried codes exits in all cases
305     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 247     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
306     return NULL; 248     return NULL;
307     // Return handler code: 249     // Return handler code:
308     try_return_handler_1:; 250     try_return_handler_1:;
309     CHECK_OBJECT( (PyObject *)var_closure_var ); 251     CHECK_OBJECT( (PyObject *)var_closure_var );
310     Py_DECREF( var_closure_var ); 252     Py_DECREF( var_closure_var );
311     var_closure_var = NULL; 253     var_closure_var = NULL;
n 312   n
313     Py_XDECREF( var_empty );
314     var_empty = NULL;
315 254
316     goto function_return_exit; 255     goto function_return_exit;
317     // Exception handler code: 256     // Exception handler code:
318     try_except_handler_1:; 257     try_except_handler_1:;
319     exception_keeper_type_1 = exception_type; 258     exception_keeper_type_1 = exception_type;
323     exception_type = NULL; 262     exception_type = NULL;
324     exception_value = NULL; 263     exception_value = NULL;
325     exception_tb = NULL; 264     exception_tb = NULL;
326     exception_lineno = 0; 265     exception_lineno = 0;
327 266
n 328     CHECK_OBJECT( (PyObject *)var_closure_var ); n
329     Py_DECREF( var_closure_var );
330     var_closure_var = NULL;
331  
332     Py_XDECREF( var_empty );
333     var_empty = NULL;
334  
335     // Re-raise. 267     // Re-raise.
336     exception_type = exception_keeper_type_1; 268     exception_type = exception_keeper_type_1;
337     exception_value = exception_keeper_value_1; 269     exception_value = exception_keeper_value_1;
338     exception_tb = exception_keeper_tb_1; 270     exception_tb = exception_keeper_tb_1;
339     exception_lineno = exception_keeper_lineno_1; 271     exception_lineno = exception_keeper_lineno_1;
353 function_return_exit: 285 function_return_exit:
354 286
355 CHECK_OBJECT( tmp_return_value ); 287 CHECK_OBJECT( tmp_return_value );
356 assert( had_error || !ERROR_OCCURRED() ); 288 assert( had_error || !ERROR_OCCURRED() );
357 return tmp_return_value; 289 return tmp_return_value;
n 358   n
359 }
360  
361  
362 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
363 {
364     // Preserve error status for checks
365 #ifndef __NUITKA_NO_ASSERT__
366     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
367 #endif
368  
369     // Local variable declarations.
370     PyObject *tmp_return_value;
371     tmp_return_value = NULL;
372  
373     // Actual function code.
374     tmp_return_value = Nuitka_Generator_New(
375         __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context,
376         module___main__,
377         const_str_plain_empty,
378 #if PYTHON_VERSION >= 350
379         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
380 #endif
381         codeobj_3db200e92a9fdb0e0fce14a9bc2a5b48,
382         1
383     );
384  
385     ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] = self->m_closure[0];
386     Py_INCREF( ((struct Nuitka_GeneratorObject *)tmp_return_value)->m_closure[0] );
387     assert( Py_SIZE( tmp_return_value ) >= 1 ); 
388  
389  
390     goto function_return_exit;
391  
392     // Return statement must have exited already.
393     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
394     return NULL;
395  
396 function_return_exit:
397  
398 CHECK_OBJECT( tmp_return_value );
399 assert( had_error || !ERROR_OCCURRED() );
400 return tmp_return_value;
401  
402 }
403  
404  
405  
406 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
407 struct __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_locals {
408     PyObject *exception_type
409     PyObject *exception_value
410     PyTracebackObject *exception_tb
411     int exception_lineno
412     PyObject *tmp_expression_name_1;
413     char const *type_description_1
414 };
415 #endif
416  
417 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
418 static PyObject *__main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
419 #else
420 static void __main__$$$function_1_calledRepeatedly$$$function_1_empty$$$genobj_1_empty_context( struct Nuitka_GeneratorObject *generator )
421 #endif
422 {
423     CHECK_OBJECT( (PyObject *)generator );
424     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
425  
426     // Local variable initialization
427     PyObject *exception_type = NULL;
428     PyObject *exception_value = NULL;
429     PyTracebackObject *exception_tb = NULL;
430     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
431     PyObject *tmp_expression_name_1;
432     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
433     static struct Nuitka_FrameObject *cache_frame_generator = NULL;
434  
435     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
436  
437     // Dispatch to yield based on return label index:
438  
439  
440     // Actual function code.
441     MAKE_OR_REUSE_FRAME( cache_frame_generator, codeobj_3db200e92a9fdb0e0fce14a9bc2a5b48, module___main__, sizeof(void *) );
442     generator->m_frame = cache_frame_generator;
443  
444     // Mark the frame object as in use, ref count 1 will be up for reuse.
445     Py_INCREF( generator->m_frame );
446     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
447  
448 #if PYTHON_VERSION >= 340
449     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
450 #endif
451  
452     Py_CLEAR( generator->m_frame->m_frame.f_back );
453  
454     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
455     Py_INCREF( generator->m_frame->m_frame.f_back );
456  
457     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
458     Py_INCREF( generator->m_frame );
459  
460     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
461  
462 #if PYTHON_VERSION >= 300
463     // Accept currently existing exception as the one to publish again when we
464     // yield or yield from.
465  
466     PyThreadState *thread_state = PyThreadState_GET();
467  
468     generator->m_frame->m_frame.f_exc_type = thread_state->exc_type;
469     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
470     Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
471     generator->m_frame->m_frame.f_exc_value = thread_state->exc_value;
472     Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
473     generator->m_frame->m_frame.f_exc_traceback = thread_state->exc_traceback;
474     Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
475 #endif
476  
477     // Framed code:
478     if ( generator->m_closure[0] == NULL )
479     {
480         tmp_expression_name_1 = NULL;
481     }
482     else
483     {
484         tmp_expression_name_1 = PyCell_GET( generator->m_closure[0] );
485     }
486  
487     if ( tmp_expression_name_1 == NULL )
488     {
489  
490         exception_type = PyExc_NameError;
491         Py_INCREF( exception_type );
492         exception_value = PyUnicode_FromFormat( "free variable '%s' referenced before assignment in enclosing scope", "closure_var" );
493         exception_tb = NULL;
494         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
495         CHAIN_EXCEPTION( exception_value );
496  
497         exception_lineno = 29;
498         type_description_1 = "c";
499         goto frame_exception_exit_1;
500     }
501  
502     Py_INCREF( tmp_expression_name_1 );
503     tmp_unused = GENERATOR_YIELD( generator, tmp_expression_name_1 );
504     if ( tmp_unused == NULL )
505     {
506         assert( ERROR_OCCURRED() );
507  
508         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
509  
510  
511         exception_lineno = 29;
512         type_description_1 = "c";
513         goto frame_exception_exit_1;
514     }
515  
516     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
517  
518 #if PYTHON_VERSION >= 300
519     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
520     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
521     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
522 #endif
523  
524     // Allow re-use of the frame again.
525     Py_DECREF( generator->m_frame );
526     goto frame_no_exception_1;
527  
528     frame_exception_exit_1:;
529  
530     // If it's not an exit exception, consider and create a traceback for it.
531     if ( !EXCEPTION_MATCH_GENERATOR( exception_type ) )
532     {
533         if ( exception_tb == NULL )
534         {
535             exception_tb = MAKE_TRACEBACK( generator->m_frame, exception_lineno );
536         }
537         else if ( exception_tb->tb_frame != &generator->m_frame->m_frame )
538         {
539             exception_tb = ADD_TRACEBACK( exception_tb, generator->m_frame, exception_lineno );
540         }
541  
542         Nuitka_Frame_AttachLocals(
543             (struct Nuitka_FrameObject *)generator->m_frame,
544             type_description_1,
545             generator->m_closure[0]
546         );
547  
548  
549         // Release cached frame.
550         if ( generator->m_frame == cache_frame_generator )
551         {
552             Py_DECREF( generator->m_frame );
553         }
554         cache_frame_generator = NULL;
555  
556         assertFrameObject( generator->m_frame );
557     }
558  
559 #if PYTHON_VERSION >= 300
560     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
561     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
562     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
563 #endif
564  
565     Py_DECREF( generator->m_frame );
566     // Return the error.
567     goto function_exception_exit;
568  
569     frame_no_exception_1:;
570  
571  
572 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
573     return NULL;
574 #else
575     generator->m_yielded = NULL;
576     return;
577 #endif
578  
579     function_exception_exit:
580     assert( exception_type );
581     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
582  
583 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
584     return NULL;
585 #else
586     generator->m_yielded = NULL;
587     return;
588 #endif
589 290
590 } 291 }
591 292
592 293
593 294
608         module___main__, 309         module___main__,
609         Py_None, 310         Py_None,
610         0 311         0
611     ); 312     );
612 313
t 613   t
614     return (PyObject *)result;
615 }
616  
617  
618  
619 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_CellObject *closure_closure_var )
620 {
621     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
622         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
623         const_str_plain_empty,
624 #if PYTHON_VERSION >= 330
625         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
626 #endif
627         codeobj_3db200e92a9fdb0e0fce14a9bc2a5b48,
628         NULL,
629 #if PYTHON_VERSION >= 300
630         NULL,
631         const_dict_empty,
632 #endif
633         module___main__,
634         Py_None,
635         1
636     );
637  
638 result->m_closure[0] = closure_closure_var;
639 Py_INCREF( result->m_closure[0] );
640 314
641     return (PyObject *)result; 315     return (PyObject *)result;
642 } 316 }
643 317
644 318