Construct FunctionCreationGeneratorClosure

Performance Diagrams

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