Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)23540249888.11538461538461257.0CPython 2.781584381240.03846153846155418.4716218655812Nuitka (master)81884259391.96153846153845418.1568228811299Nuitka (develop)81884223543.8846153846154418.1568606723765Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23509232188.11538461538461257.0CPython 3.591584801240.03846153846155407.846764578074Nuitka (master)92029461391.96153846153845407.379363829059Nuitka (develop)92084289543.8846153846154407.3217318219817Nuitka (factory)Construct GeneratorExpressionCreationTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
# construct_begin
    gen = (x for x in range(3))
# construct_alternative



    x = next(gen)
    next(gen)

    return x

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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a generator iterator step or not.
# construct_begin

# construct_alternative
    gen = iter((1,2,3))
# construct_end

    x = next(gen)
    next(gen)

    return x

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
19 # 19 #
20 20
21 def calledRepeatedly(): 21 def calledRepeatedly():
22     # We measure making a generator iterator step or not. 22     # We measure making a generator iterator step or not.
23 # construct_begin 23 # construct_begin
n 24     gen = (x for x in range(3)) n 24  
25 # construct_alternative 25 # construct_alternative
t 26   t 26     gen = iter((1,2,3))
27   27 # construct_end
28 28
29     x = next(gen) 29     x = next(gen)
30     next(gen) 30     next(gen)
31 31
32     return x 32     return x

Context Diff of Generated Code


Construct
Baseline
29 29
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. */
n 34 static PyObject *const_str_digest_57aac74124c55d29a6f122835861daff; n
35 static PyObject *const_str_plain_itertools; 34 static PyObject *const_str_plain_itertools;
n 36 static PyObject *const_str_plain_False; n
37 static PyObject *const_str_angle_genexpr;
38 static PyObject *const_xrange_0_3;
39 extern PyObject *const_int_pos_1; 35 extern PyObject *const_int_pos_1;
40 extern PyObject *const_str_plain___file__; 36 extern PyObject *const_str_plain___file__;
n 41 static PyObject *const_str_digest_b9c4baf879ebd882d40843df3a4dead7; n
42 extern PyObject *const_int_0; 37 extern PyObject *const_int_0;
43 extern PyObject *const_str_plain_print; 38 extern PyObject *const_str_plain_print;
n n 39 static PyObject *const_int_pos_50000;
40 static PyObject *const_str_plain_gen;
44 static PyObject *const_int_pos_3; 41 static PyObject *const_int_pos_3;
n 45 static PyObject *const_str_plain_gen; n
46 static PyObject *const_int_pos_50000;
47 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 42 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
48 static PyObject *const_str_plain_calledRepeatedly; 43 static PyObject *const_str_plain_calledRepeatedly;
49 static PyObject *const_str_plain_True; 44 static PyObject *const_str_plain_True;
50 static PyObject *const_str_angle_module; 45 static PyObject *const_str_angle_module;
51 static PyObject *const_str_plain_None; 46 static PyObject *const_str_plain_None;
52 static PyObject *const_str_plain_x; 47 static PyObject *const_str_plain_x;
53 extern PyObject *const_tuple_empty; 48 extern PyObject *const_tuple_empty;
54 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 49 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
55 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple; 50 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple;
56 static PyObject *const_str_plain_repeat; 51 static PyObject *const_str_plain_repeat;
n 57 static PyObject *const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple; n 52 static PyObject *const_int_pos_2;
58 static PyObject *const_tuple_none_int_pos_50000_tuple; 53 static PyObject *const_tuple_none_int_pos_50000_tuple;
59 extern PyObject *const_str_plain___main__; 54 extern PyObject *const_str_plain___main__;
n n 55 static PyObject *const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
60 extern PyObject *const_str_plain___doc__; 56 extern PyObject *const_str_plain___doc__;
61 extern PyObject *const_str_plain___cached__; 57 extern PyObject *const_str_plain___cached__;
62 static PyObject *const_str_digest_fa26b576cdc180355aa15ffde4325a65; 58 static PyObject *const_str_digest_fa26b576cdc180355aa15ffde4325a65;
63 static PyObject *module_filename_obj; 59 static PyObject *module_filename_obj;
64 60
65 static bool constants_created = false; 61 static bool constants_created = false;
66 62
67 static void createModuleConstants( void ) 63 static void createModuleConstants( void )
68 { 64 {
n 69     const_str_digest_57aac74124c55d29a6f122835861daff = UNSTREAM_STRING( &constant_bin[ 0 ], 35, 0 ); n
70     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 35 ], 9, 1 ); 65     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 );
66     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
71     const_str_plain_False = UNSTREAM_STRING( &constant_bin[ 44 ], 5, 1 ); 67     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 9 ], 3, 1 );
72     const_str_angle_genexpr = UNSTREAM_STRING( &constant_bin[ 26 ], 9, 0 );
73     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul ); 68     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul );
n 74     const_xrange_0_3 = BUILTIN_XRANGE3( const_int_0, const_int_pos_3, const_int_pos_1 ); n
75     const_str_digest_b9c4baf879ebd882d40843df3a4dead7 = UNSTREAM_STRING( &constant_bin[ 49 ], 2, 1 );
76     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 );
77     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
78     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 69     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 79     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 51 ], 3, 0 ); n 70     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 12 ], 3, 0 );
80     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 71     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( &constant_bin[ 0 ], 16, 1 ); n 72     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 15 ], 16, 1 );
82     const_str_plain_True = UNSTREAM_STRING( &constant_bin[ 54 ], 4, 1 ); 73     const_str_plain_True = UNSTREAM_STRING( &constant_bin[ 31 ], 4, 1 );
83     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 58 ], 8, 0 ); 74     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 35 ], 8, 0 );
84     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 66 ], 4, 1 ); 75     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 43 ], 4, 1 );
85     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 76     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 47 ], 1, 1 );
86     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 ); 77     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 );
87     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen ); 78     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen );
88     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 79     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
n 89     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 70 ], 6, 1 ); n 80     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 48 ], 6, 1 );
90     const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple = PyTuple_New( 2 ); 81     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul );
91     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 0, const_str_digest_b9c4baf879ebd882d40843df3a4dead7 ); Py_INCREF( const_str_digest_b9c4baf879ebd882d40843df3a4dead7 );
92     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
93     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 82     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
94     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 );
95     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 );
n n 85     const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple = PyTuple_New( 3 );
86     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 0, const_int_pos_1 ); Py_INCREF( const_int_pos_1 );
87     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 1, const_int_pos_2 ); Py_INCREF( const_int_pos_2 );
88     PyTuple_SET_ITEM( const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple, 2, const_int_pos_3 ); Py_INCREF( const_int_pos_3 );
96     const_str_digest_fa26b576cdc180355aa15ffde4325a65 = UNSTREAM_STRING( &constant_bin[ 76 ], 85, 0 ); 89     const_str_digest_fa26b576cdc180355aa15ffde4325a65 = UNSTREAM_STRING( &constant_bin[ 54 ], 85, 0 );
97 90
98     constants_created = true; 91     constants_created = true;
99 } 92 }
100 93
101 #ifndef __NUITKA_NO_ASSERT__ 94 #ifndef __NUITKA_NO_ASSERT__
107 100
108 } 101 }
109 #endif 102 #endif
110 103
111 // The module code objects. 104 // The module code objects.
n 112 static PyCodeObject *codeobj_849ab314ba3e755e6aad907967fadc1a; n
113 static PyCodeObject *codeobj_8bb10321eca32befb007f9ed4a4927ec; 105 static PyCodeObject *codeobj_8bb10321eca32befb007f9ed4a4927ec;
114 static PyCodeObject *codeobj_796b569be7b87f262640f6f1f3be2273; 106 static PyCodeObject *codeobj_796b569be7b87f262640f6f1f3be2273;
115 /* For use in "MainProgram.c". */ 107 /* For use in "MainProgram.c". */
116 PyCodeObject *codeobj_main = NULL; 108 PyCodeObject *codeobj_main = NULL;
117 109
118 static void createModuleCodeObjects(void) 110 static void createModuleCodeObjects(void)
119 { 111 {
120     module_filename_obj = const_str_digest_fa26b576cdc180355aa15ffde4325a65; 112     module_filename_obj = const_str_digest_fa26b576cdc180355aa15ffde4325a65;
n 121     codeobj_849ab314ba3e755e6aad907967fadc1a = MAKE_CODEOBJ( module_filename_obj, const_str_angle_genexpr, 24, const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, 0, CO_GENERATOR | CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); n
122     codeobj_8bb10321eca32befb007f9ed4a4927ec = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 113     codeobj_8bb10321eca32befb007f9ed4a4927ec = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
123     codeobj_main = codeobj_8bb10321eca32befb007f9ed4a4927ec; 114     codeobj_main = codeobj_8bb10321eca32befb007f9ed4a4927ec;
124     codeobj_796b569be7b87f262640f6f1f3be2273 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 21, const_tuple_str_plain_gen_str_plain_x_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 115     codeobj_796b569be7b87f262640f6f1f3be2273 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 21, const_tuple_str_plain_gen_str_plain_x_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
125 } 116 }
126 117
127 // The module function declarations. 118 // The module function declarations.
n 128 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void ); n
129  
130  
131 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 119 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
132 120
133 121
134 // The module function definitions. 122 // The module function definitions.
135 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 123 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
140 #endif 128 #endif
141 129
142     // Local variable declarations. 130     // Local variable declarations.
143     PyObject *var_gen = NULL; 131     PyObject *var_gen = NULL;
144     PyObject *var_x = NULL; 132     PyObject *var_x = NULL;
n 145     PyObject *tmp_genexpr_1__$0 = NULL; n
146     struct Nuitka_FrameObject *frame_796b569be7b87f262640f6f1f3be2273; 133     struct Nuitka_FrameObject *frame_796b569be7b87f262640f6f1f3be2273;
147     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 134     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
148     PyObject *exception_type = NULL; 135     PyObject *exception_type = NULL;
149     PyObject *exception_value = NULL; 136     PyObject *exception_value = NULL;
150     PyTracebackObject *exception_tb = NULL; 137     PyTracebackObject *exception_tb = NULL;
158     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 145     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
159 146
160     // Actual function code. 147     // Actual function code.
161     { 148     {
162     PyObject *tmp_assign_source_1; 149     PyObject *tmp_assign_source_1;
n 163     PyObject *tmp_outline_return_value_1; n
164     {
165     PyObject *tmp_assign_source_2;
166     PyObject *tmp_iter_arg_1; 150     PyObject *tmp_iter_arg_1;
n 167     tmp_iter_arg_1 = const_xrange_0_3; n 151     tmp_iter_arg_1 = const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
168     tmp_assign_source_2 = MAKE_ITERATOR( tmp_iter_arg_1 ); 152     tmp_assign_source_1 = MAKE_ITERATOR( tmp_iter_arg_1 );
169     assert( !(tmp_assign_source_2 == NULL) ); 153     assert( !(tmp_assign_source_1 == NULL) );
170     assert( tmp_genexpr_1__$0 == NULL );
171     tmp_genexpr_1__$0 = tmp_assign_source_2;
172  
173     }
174     {
175     // Tried code:
176     {
177     tmp_outline_return_value_1 = __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker();
178  
179     ((struct Nuitka_GeneratorObject *)tmp_outline_return_value_1)->m_closure[0] = PyCell_NEW0( tmp_genexpr_1__$0 );
180  
181  
182     goto try_return_handler_1;
183     }
184     // tried codes exits in all cases
185     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
186     return NULL;
187     // Return handler code:
188     try_return_handler_1:;
189     {
190     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
191     Py_DECREF( tmp_genexpr_1__$0 );
192     tmp_genexpr_1__$0 = NULL;
193  
194     }
195     {
196     goto outline_result_1;
197     }
198     // End of try:
199     }
200     {
201     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
202     Py_DECREF( tmp_genexpr_1__$0 );
203     tmp_genexpr_1__$0 = NULL;
204  
205     }
206     // Return statement must have exited already.
207     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
208     return NULL;
209     outline_result_1:;
210     tmp_assign_source_1 = tmp_outline_return_value_1;
211     assert( var_gen == NULL ); 154     assert( var_gen == NULL );
212     var_gen = tmp_assign_source_1; 155     var_gen = tmp_assign_source_1;
213 156
214     } 157     }
215     { 158     {
223     // Mark the frame object as in use, ref count 1 will be up for reuse. 166     // Mark the frame object as in use, ref count 1 will be up for reuse.
224     assert( Py_REFCNT( frame_796b569be7b87f262640f6f1f3be2273 ) == 2 ); // Frame stack 167     assert( Py_REFCNT( frame_796b569be7b87f262640f6f1f3be2273 ) == 2 ); // Frame stack
225 168
226     // Framed code: 169     // Framed code:
227     { 170     {
n 228     PyObject *tmp_assign_source_3; n 171     PyObject *tmp_assign_source_2;
229     PyObject *tmp_value_name_1; 172     PyObject *tmp_value_name_1;
230     tmp_value_name_1 = var_gen; 173     tmp_value_name_1 = var_gen;
231 174
232     CHECK_OBJECT( tmp_value_name_1 ); 175     CHECK_OBJECT( tmp_value_name_1 );
n 233     tmp_assign_source_3 = ITERATOR_NEXT( tmp_value_name_1 ); n 176     tmp_assign_source_2 = ITERATOR_NEXT( tmp_value_name_1 );
234     if ( tmp_assign_source_3 == NULL ) 177     if ( tmp_assign_source_2 == NULL )
235     { 178     {
236         if ( !ERROR_OCCURRED() ) 179         if ( !ERROR_OCCURRED() )
237         { 180         {
238             exception_type = PyExc_StopIteration; 181             exception_type = PyExc_StopIteration;
239             Py_INCREF( exception_type ); 182             Py_INCREF( exception_type );
249         type_description_1 = "oo"; 192         type_description_1 = "oo";
250         exception_lineno = 29; 193         exception_lineno = 29;
251         goto frame_exception_exit_1; 194         goto frame_exception_exit_1;
252     } 195     }
253     assert( var_x == NULL ); 196     assert( var_x == NULL );
n 254     var_x = tmp_assign_source_3; n 197     var_x = tmp_assign_source_2;
255 198
256     } 199     }
257     { 200     {
258     PyObject *tmp_value_name_2; 201     PyObject *tmp_value_name_2;
259     tmp_value_name_2 = var_gen; 202     tmp_value_name_2 = var_gen;
340 283
341     // Put the previous frame back on top. 284     // Put the previous frame back on top.
342     popFrameStack(); 285     popFrameStack();
343 286
344     // Return the error. 287     // Return the error.
n 345     goto try_except_handler_2; n 288     goto try_except_handler_1;
346 289
347     frame_no_exception_1:; 290     frame_no_exception_1:;
348 291
349     { 292     {
350     tmp_return_value = var_x; 293     tmp_return_value = var_x;
359         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 302         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
360         CHAIN_EXCEPTION( exception_value ); 303         CHAIN_EXCEPTION( exception_value );
361 304
362 305
363 306
n 364         goto try_except_handler_2; n 307         goto try_except_handler_1;
365     } 308     }
366 309
367     Py_INCREF( tmp_return_value ); 310     Py_INCREF( tmp_return_value );
n 368     goto try_return_handler_2; n 311     goto try_return_handler_1;
369     } 312     }
370     // tried codes exits in all cases 313     // tried codes exits in all cases
371     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 314     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
372     return NULL; 315     return NULL;
373     // Return handler code: 316     // Return handler code:
n 374     try_return_handler_2:; n 317     try_return_handler_1:;
375     { 318     {
376     Py_XDECREF( var_gen ); 319     Py_XDECREF( var_gen );
377     var_gen = NULL; 320     var_gen = NULL;
378 321
379     } 322     }
384     } 327     }
385     { 328     {
386     goto function_return_exit; 329     goto function_return_exit;
387     } 330     }
388     // Exception handler code: 331     // Exception handler code:
n 389     try_except_handler_2:; n 332     try_except_handler_1:;
390     exception_keeper_type_1 = exception_type; 333     exception_keeper_type_1 = exception_type;
391     exception_keeper_value_1 = exception_value; 334     exception_keeper_value_1 = exception_value;
392     exception_keeper_tb_1 = exception_tb; 335     exception_keeper_tb_1 = exception_tb;
393     exception_keeper_lineno_1 = exception_lineno; 336     exception_keeper_lineno_1 = exception_lineno;
394     exception_type = NULL; 337     exception_type = NULL;
431 374
432 CHECK_OBJECT( tmp_return_value ); 375 CHECK_OBJECT( tmp_return_value );
433 assert( had_error || !ERROR_OCCURRED() ); 376 assert( had_error || !ERROR_OCCURRED() );
434 return tmp_return_value; 377 return tmp_return_value;
435 378
t 436 } t
437  
438  
439  
440 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
441  
442 };
443  
444 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
445 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
446 #else
447 static void __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator )
448 #endif
449 {
450     CHECK_OBJECT( (PyObject *)generator );
451     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
452  
453     // Heap access if used.
454  
455  
456     // Dispatch to yield based on return label index:
457  
458  
459     // Local variable initialization
460     PyObject *var_x = NULL;
461     PyObject *tmp_iter_value_0 = NULL;
462     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
463     PyObject *exception_type = NULL;
464     PyObject *exception_value = NULL;
465     PyTracebackObject *exception_tb = NULL;
466     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
467     PyObject *exception_keeper_type_1;
468     PyObject *exception_keeper_value_1;
469     PyTracebackObject *exception_keeper_tb_1;
470     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
471     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
472     PyObject *exception_keeper_type_2;
473     PyObject *exception_keeper_value_2;
474     PyTracebackObject *exception_keeper_tb_2;
475     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
476     static struct Nuitka_FrameObject *cache_m_frame = NULL;
477     PyObject *exception_keeper_type_3;
478     PyObject *exception_keeper_value_3;
479     PyTracebackObject *exception_keeper_tb_3;
480     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_3;
481  
482     // Actual function code.
483     {
484     // Tried code:
485     MAKE_OR_REUSE_FRAME( cache_m_frame, codeobj_849ab314ba3e755e6aad907967fadc1a, module___main__, sizeof(void *)+sizeof(void *) );
486     generator->m_frame = cache_m_frame;
487  
488     // Mark the frame object as in use, ref count 1 will be up for reuse.
489     Py_INCREF( generator->m_frame );
490     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
491  
492 #if PYTHON_VERSION >= 340
493     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
494 #endif
495  
496     Py_CLEAR( generator->m_frame->m_frame.f_back );
497  
498     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
499     Py_INCREF( generator->m_frame->m_frame.f_back );
500  
501     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
502     Py_INCREF( generator->m_frame );
503  
504     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
505  
506 #if PYTHON_VERSION >= 300
507     // Accept currently existing exception as the one to publish again when we
508     // yield or yield from.
509  
510     PyThreadState *thread_state = PyThreadState_GET();
511  
512 #if PYTHON_VERSION < 370
513     generator->m_frame->m_frame.f_exc_type = EXC_TYPE( thread_state );
514     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
515     Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
516     generator->m_frame->m_frame.f_exc_value = EXC_VALUE( thread_state );
517     Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
518     generator->m_frame->m_frame.f_exc_traceback = EXC_TRACEBACK( thread_state );
519     Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
520 #else
521     generator->m_exc_state.exc_type = EXC_TYPE( thread_state );
522     if ( generator->m_exc_state.exc_type == Py_None ) generator->m_exc_state.exc_type = NULL;
523     Py_XINCREF( generator->m_exc_state.exc_type );
524     generator->m_exc_state.exc_value = EXC_VALUE( thread_state );
525     Py_XINCREF( generator->m_exc_state.exc_value );
526     generator->m_exc_state.exc_traceback = EXC_TRACEBACK( thread_state );
527     Py_XINCREF( generator->m_exc_state.exc_traceback );
528  
529 #endif
530  
531 #endif
532  
533     // Framed code:
534     {
535     // Tried code:
536     {
537     loop_start_1:;
538     {
539     // Tried code:
540     {
541     PyObject *tmp_assign_source_1;
542     PyObject *tmp_value_name_1;
543     if ( generator->m_closure[0] == NULL )
544     {
545         tmp_value_name_1 = NULL;
546     }
547     else
548     {
549         tmp_value_name_1 = PyCell_GET( generator->m_closure[0] );
550     }
551  
552     CHECK_OBJECT( tmp_value_name_1 );
553     tmp_assign_source_1 = ITERATOR_NEXT( tmp_value_name_1 );
554     if ( tmp_assign_source_1 == NULL )
555     {
556         if ( !ERROR_OCCURRED() )
557         {
558             exception_type = PyExc_StopIteration;
559             Py_INCREF( exception_type );
560             exception_value = NULL;
561             exception_tb = NULL;
562         }
563         else
564         {
565             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
566         }
567  
568  
569         type_description_1 = "No";
570         exception_lineno = 24;
571         goto try_except_handler_3;
572     }
573     {
574         PyObject *old = tmp_iter_value_0;
575         tmp_iter_value_0 = tmp_assign_source_1;
576         Py_XDECREF( old );
577     }
578  
579     }
580     goto try_end_1;
581     // Exception handler code:
582     try_except_handler_3:;
583     exception_keeper_type_1 = exception_type;
584     exception_keeper_value_1 = exception_value;
585     exception_keeper_tb_1 = exception_tb;
586     exception_keeper_lineno_1 = exception_lineno;
587     exception_type = NULL;
588     exception_value = NULL;
589     exception_tb = NULL;
590     exception_lineno = 0;
591  
592     {
593     PyObject *tmp_compare_left_1;
594     PyObject *tmp_compare_right_1;
595     int tmp_exc_match_exception_match_1;
596     tmp_compare_left_1 = exception_keeper_type_1;
597     tmp_compare_right_1 = PyExc_StopIteration;
598     tmp_exc_match_exception_match_1 = EXCEPTION_MATCH_BOOL( tmp_compare_left_1, tmp_compare_right_1 );
599     if ( tmp_exc_match_exception_match_1 == -1 )
600     {
601         assert( ERROR_OCCURRED() );
602  
603         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
604  
605         Py_DECREF( exception_keeper_type_1 );
606         Py_XDECREF( exception_keeper_value_1 );
607         Py_XDECREF( exception_keeper_tb_1 );
608  
609         exception_lineno = 24;
610         type_description_1 = "No";
611         goto try_except_handler_2;
612     }
613     if ( tmp_exc_match_exception_match_1 == 1 )
614     {
615         goto branch_yes_1;
616     }
617     else
618     {
619         goto branch_no_1;
620     }
621     branch_yes_1:;
622     {
623     Py_DECREF( exception_keeper_type_1 );
624     Py_XDECREF( exception_keeper_value_1 );
625     Py_XDECREF( exception_keeper_tb_1 );
626     goto loop_end_1;
627     }
628     goto branch_end_1;
629     branch_no_1:;
630     {
631     // Re-raise.
632     exception_type = exception_keeper_type_1;
633     exception_value = exception_keeper_value_1;
634     exception_tb = exception_keeper_tb_1;
635     exception_lineno = exception_keeper_lineno_1;
636  
637     goto try_except_handler_2;
638     }
639     branch_end_1:;
640     }
641     // End of try:
642     try_end_1:;
643     }
644     {
645     PyObject *tmp_assign_source_2;
646     tmp_assign_source_2 = tmp_iter_value_0;
647  
648     CHECK_OBJECT( tmp_assign_source_2 );
649     {
650         PyObject *old = var_x;
651         var_x = tmp_assign_source_2;
652         Py_INCREF( var_x );
653         Py_XDECREF( old );
654     }
655  
656     }
657     {
658     PyObject *tmp_expression_name_1;
659     tmp_expression_name_1 = var_x;
660  
661     CHECK_OBJECT( tmp_expression_name_1 );
662     Py_INCREF( tmp_expression_name_1 );
663     tmp_unused = GENERATOR_YIELD( generator, tmp_expression_name_1 );
664     if ( tmp_unused == NULL )
665     {
666         assert( ERROR_OCCURRED() );
667  
668         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
669  
670  
671         exception_lineno = 24;
672         type_description_1 = "No";
673         goto try_except_handler_2;
674     }
675     }
676     if ( CONSIDER_THREADING() == false )
677     {
678         assert( ERROR_OCCURRED() );
679  
680         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
681  
682  
683         exception_lineno = 24;
684         type_description_1 = "No";
685         goto try_except_handler_2;
686     }
687     goto loop_start_1;
688     loop_end_1:;
689     }
690     goto try_end_2;
691     // Exception handler code:
692     try_except_handler_2:;
693     exception_keeper_type_2 = exception_type;
694     exception_keeper_value_2 = exception_value;
695     exception_keeper_tb_2 = exception_tb;
696     exception_keeper_lineno_2 = exception_lineno;
697     exception_type = NULL;
698     exception_value = NULL;
699     exception_tb = NULL;
700     exception_lineno = 0;
701  
702     {
703     Py_XDECREF( tmp_iter_value_0 );
704     tmp_iter_value_0 = NULL;
705  
706     }
707     {
708     // Re-raise.
709     exception_type = exception_keeper_type_2;
710     exception_value = exception_keeper_value_2;
711     exception_tb = exception_keeper_tb_2;
712     exception_lineno = exception_keeper_lineno_2;
713  
714     goto frame_exception_exit_1;
715     }
716     // End of try:
717     try_end_2:;
718     }
719  
720     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
721  
722 #if PYTHON_VERSION >= 370
723     Py_CLEAR( generator->m_exc_state.exc_type );
724     Py_CLEAR( generator->m_exc_state.exc_value );
725     Py_CLEAR( generator->m_exc_state.exc_traceback );
726 #elif PYTHON_VERSION >= 300
727     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
728     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
729     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
730 #endif
731  
732     // Allow re-use of the frame again.
733     Py_DECREF( generator->m_frame );
734     goto frame_no_exception_1;
735  
736     frame_exception_exit_1:;
737  
738     // If it's not an exit exception, consider and create a traceback for it.
739     if ( !EXCEPTION_MATCH_GENERATOR( exception_type ) )
740     {
741         if ( exception_tb == NULL )
742         {
743             exception_tb = MAKE_TRACEBACK( generator->m_frame, exception_lineno );
744         }
745         else if ( exception_tb->tb_frame != &generator->m_frame->m_frame )
746         {
747             exception_tb = ADD_TRACEBACK( exception_tb, generator->m_frame, exception_lineno );
748         }
749  
750         Nuitka_Frame_AttachLocals(
751             (struct Nuitka_FrameObject *)generator->m_frame,
752             type_description_1,
753             NULL,
754             var_x
755         );
756  
757  
758         // Release cached frame.
759         if ( generator->m_frame == cache_m_frame )
760         {
761             Py_DECREF( generator->m_frame );
762         }
763         cache_m_frame = NULL;
764  
765         assertFrameObject( generator->m_frame );
766     }
767  
768 #if PYTHON_VERSION >= 370
769     Py_CLEAR( generator->m_exc_state.exc_type );
770     Py_CLEAR( generator->m_exc_state.exc_value );
771     Py_CLEAR( generator->m_exc_state.exc_traceback );
772 #elif PYTHON_VERSION >= 300
773     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
774     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
775     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
776 #endif
777  
778     Py_DECREF( generator->m_frame );
779     // Return the error.
780     goto try_except_handler_1;
781  
782     frame_no_exception_1:;
783  
784     goto try_end_3;
785     // Exception handler code:
786     try_except_handler_1:;
787     exception_keeper_type_3 = exception_type;
788     exception_keeper_value_3 = exception_value;
789     exception_keeper_tb_3 = exception_tb;
790     exception_keeper_lineno_3 = exception_lineno;
791     exception_type = NULL;
792     exception_value = NULL;
793     exception_tb = NULL;
794     exception_lineno = 0;
795  
796     {
797     Py_XDECREF( var_x );
798     var_x = NULL;
799  
800     }
801     {
802     // Re-raise.
803     exception_type = exception_keeper_type_3;
804     exception_value = exception_keeper_value_3;
805     exception_tb = exception_keeper_tb_3;
806     exception_lineno = exception_keeper_lineno_3;
807  
808     goto function_exception_exit;
809     }
810     // End of try:
811     try_end_3:;
812     }
813     {
814     Py_XDECREF( tmp_iter_value_0 );
815     tmp_iter_value_0 = NULL;
816  
817     }
818     {
819     Py_XDECREF( var_x );
820     var_x = NULL;
821  
822     }
823  
824  
825 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
826     return NULL;
827 #else
828     generator->m_yielded = NULL;
829     return;
830 #endif
831  
832     function_exception_exit:
833     assert( exception_type );
834     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
835  
836 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
837     return NULL;
838 #else
839     generator->m_yielded = NULL;
840     return;
841 #endif
842  
843 }
844  
845 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_maker( void )
846 {
847     return Nuitka_Generator_New(
848         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
849         module___main__,
850         const_str_angle_genexpr,
851 #if PYTHON_VERSION >= 350
852         const_str_digest_57aac74124c55d29a6f122835861daff,
853 #endif
854         codeobj_849ab314ba3e755e6aad907967fadc1a,
855         1,
856         sizeof(struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals)
857     );
858 } 379 }
859 380
860 381
861 382
862 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ) 383 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  )