Construct GeneratorExpressionCreation

Performance Diagrams

Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)20452746688.11538461538461257.0CPython 2.779978109240.03846153846155407.4837607417179Nuitka (master)80277794391.96153846153845407.1216735585791Nuitka (develop)80277782543.8846153846154407.1216880572901Nuitka (factory)Construct GeneratorExpressionCreationTicks Construct GeneratorExpressionCreation 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)24099979188.11538461538461257.0CPython 3.590253122240.03846153846155411.5720057882668Nuitka (master)90295613391.96153846153845411.5284365396624Nuitka (develop)90295634543.8846153846154411.52841500676783Nuitka (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;
36 static PyObject *const_str_plain___package__; 35 static PyObject *const_str_plain___package__;
37 static PyObject *const_str_plain___spec__; 36 static PyObject *const_str_plain___spec__;
n 38 static PyObject *const_str_angle_genexpr; n
39 static PyObject *const_xrange_0_3;
40 extern PyObject *const_int_pos_1; 37 extern PyObject *const_int_pos_1;
41 extern PyObject *const_dict_empty; 38 extern PyObject *const_dict_empty;
42 extern PyObject *const_str_plain___file__; 39 extern PyObject *const_str_plain___file__;
n 43 static PyObject *const_str_digest_b9c4baf879ebd882d40843df3a4dead7; n
44 extern PyObject *const_int_0; 40 extern PyObject *const_int_0;
45 static PyObject *const_str_digest_623a120c3d0be1ca5293d6700c96d42f; 41 static PyObject *const_str_digest_623a120c3d0be1ca5293d6700c96d42f;
46 extern PyObject *const_str_plain_print; 42 extern PyObject *const_str_plain_print;
n n 43 static PyObject *const_int_pos_50000;
44 static PyObject *const_str_plain_gen;
47 static PyObject *const_int_pos_3; 45 static PyObject *const_int_pos_3;
n 48 static PyObject *const_str_plain_gen; n
49 static PyObject *const_int_pos_50000;
50 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 46 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
51 static PyObject *const_str_plain_calledRepeatedly; 47 static PyObject *const_str_plain_calledRepeatedly;
52 static PyObject *const_str_angle_module; 48 static PyObject *const_str_angle_module;
53 static PyObject *const_str_plain_x; 49 static PyObject *const_str_plain_x;
54 extern PyObject *const_tuple_empty; 50 extern PyObject *const_tuple_empty;
55 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 51 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
56 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple; 52 static PyObject *const_tuple_str_plain_gen_str_plain_x_tuple;
57 static PyObject *const_str_plain_repeat; 53 static PyObject *const_str_plain_repeat;
n 58 static PyObject *const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple; n 54 static PyObject *const_int_pos_2;
59 static PyObject *const_tuple_none_int_pos_50000_tuple; 55 static PyObject *const_tuple_none_int_pos_50000_tuple;
60 extern PyObject *const_str_plain___loader__; 56 extern PyObject *const_str_plain___loader__;
61 extern PyObject *const_str_plain___main__; 57 extern PyObject *const_str_plain___main__;
n n 58 static PyObject *const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
62 extern PyObject *const_str_plain___doc__; 59 extern PyObject *const_str_plain___doc__;
63 extern PyObject *const_str_plain___cached__; 60 extern PyObject *const_str_plain___cached__;
64 static PyObject *module_filename_obj; 61 static PyObject *module_filename_obj;
65 62
66 static bool constants_created = false; 63 static bool constants_created = false;
67 64
68 static void createModuleConstants( void ) 65 static void createModuleConstants( void )
69 { 66 {
n 70     const_str_digest_57aac74124c55d29a6f122835861daff = UNSTREAM_STRING( &constant_bin[ 0 ], 35, 0 ); n
71     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 35 ], 9, 1 ); 67     const_str_plain_itertools = UNSTREAM_STRING( &constant_bin[ 0 ], 9, 1 );
72     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 44 ], 11, 1 ); 68     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 9 ], 11, 1 );
73     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 55 ], 8, 1 ); 69     const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 20 ], 8, 1 );
70     const_str_digest_623a120c3d0be1ca5293d6700c96d42f = UNSTREAM_STRING( &constant_bin[ 28 ], 85, 0 );
71     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
74     const_str_angle_genexpr = UNSTREAM_STRING( &constant_bin[ 26 ], 90 ); 72     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 113 ], 31 );
75     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul ); 73     const_int_pos_3 = PyLong_FromUnsignedLong( 3ul );
n 76     const_xrange_0_3 = BUILTIN_XRANGE3( const_int_0, const_int_pos_3, const_int_pos_1 ); n
77     const_str_digest_b9c4baf879ebd882d40843df3a4dead7 = UNSTREAM_STRING( &constant_bin[ 63 ], 2, 1 );
78     const_str_digest_623a120c3d0be1ca5293d6700c96d42f = UNSTREAM_STRING( &constant_bin[ 65 ], 85, 0 );
79     const_str_plain_gen = UNSTREAM_STRING( &constant_bin[ 27 ], 3, 1 );
80     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
81     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 74     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 82     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 150 ], 3, 0 ); n 75     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 116 ], 3, 0 );
83     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 76     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 84     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 0 ], 16, 1 ); n 77     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 119 ], 16, 1 );
85     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 153 ], 8, 0 ); 78     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 135 ], 8, 0 );
86     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 31 ], 1, 1 ); 79     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 53 ], 1, 1 );
87     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 ); 80     const_tuple_str_plain_gen_str_plain_x_tuple = PyTuple_New( 2 );
88     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen ); 81     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 0, const_str_plain_gen ); Py_INCREF( const_str_plain_gen );
89     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x ); 82     PyTuple_SET_ITEM( const_tuple_str_plain_gen_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
n 90     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 161 ], 6, 1 ); n 83     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 143 ], 6, 1 );
91     const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple = PyTuple_New( 2 ); 84     const_int_pos_2 = PyLong_FromUnsignedLong( 2ul );
92     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 0, const_str_digest_b9c4baf879ebd882d40843df3a4dead7 ); Py_INCREF( const_str_digest_b9c4baf879ebd882d40843df3a4dead7 );
93     PyTuple_SET_ITEM( const_tuple_str_digest_b9c4baf879ebd882d40843df3a4dead7_str_plain_x_tuple, 1, const_str_plain_x ); Py_INCREF( const_str_plain_x );
94     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 85     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
95     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 86     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
96     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 87     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n n 88     const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple = PyTuple_New( 3 );
89     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 );
90     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 );
91     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 );
97 92
98     constants_created = true; 93     constants_created = true;
99 } 94 }
100 95
101 #ifndef __NUITKA_NO_ASSERT__ 96 #ifndef __NUITKA_NO_ASSERT__
107 102
108 } 103 }
109 #endif 104 #endif
110 105
111 // The module code objects. 106 // The module code objects.
n 112 static PyCodeObject *codeobj_e79428786c872b40b586ebec1b1ab40c; n
113 static PyCodeObject *codeobj_723a086b962d5ada2e503882c58fd4b6; 107 static PyCodeObject *codeobj_723a086b962d5ada2e503882c58fd4b6;
114 static PyCodeObject *codeobj_b76412bf2829eb288f5aee0690760b57; 108 static PyCodeObject *codeobj_b76412bf2829eb288f5aee0690760b57;
115 /* For use in "MainProgram.c". */ 109 /* For use in "MainProgram.c". */
116 PyCodeObject *codeobj_main = NULL; 110 PyCodeObject *codeobj_main = NULL;
117 111
118 static void createModuleCodeObjects(void) 112 static void createModuleCodeObjects(void)
119 { 113 {
120     module_filename_obj = const_str_digest_623a120c3d0be1ca5293d6700c96d42f; 114     module_filename_obj = const_str_digest_623a120c3d0be1ca5293d6700c96d42f;
n 121     codeobj_e79428786c872b40b586ebec1b1ab40c = 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_723a086b962d5ada2e503882c58fd4b6 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 115     codeobj_723a086b962d5ada2e503882c58fd4b6 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
123     codeobj_main = codeobj_723a086b962d5ada2e503882c58fd4b6; 116     codeobj_main = codeobj_723a086b962d5ada2e503882c58fd4b6;
124     codeobj_b76412bf2829eb288f5aee0690760b57 = 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 ); 117     codeobj_b76412bf2829eb288f5aee0690760b57 = 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 } 118 }
126 119
127 // The module function declarations. 120 // The module function declarations.
n 128 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO n
129 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value );
130 #else
131 static void __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator );
132 #endif
133  
134  
135 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 121 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
136 122
137 123
138 // The module function definitions. 124 // The module function definitions.
139 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 125 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
144 #endif 130 #endif
145 131
146     // Local variable declarations. 132     // Local variable declarations.
147     PyObject *var_gen = NULL; 133     PyObject *var_gen = NULL;
148     PyObject *var_x = NULL; 134     PyObject *var_x = NULL;
n 149     PyObject *tmp_genexpr_1__$0 = NULL; n
150     PyObject *exception_type = NULL; 135     PyObject *exception_type = NULL;
151     PyObject *exception_value = NULL; 136     PyObject *exception_value = NULL;
152     PyTracebackObject *exception_tb = NULL; 137     PyTracebackObject *exception_tb = NULL;
153     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 138     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
154     PyObject *exception_keeper_type_1; 139     PyObject *exception_keeper_type_1;
155     PyObject *exception_keeper_value_1; 140     PyObject *exception_keeper_value_1;
156     PyTracebackObject *exception_keeper_tb_1; 141     PyTracebackObject *exception_keeper_tb_1;
157     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 142     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
158     PyObject *tmp_assign_source_1; 143     PyObject *tmp_assign_source_1;
159     PyObject *tmp_assign_source_2; 144     PyObject *tmp_assign_source_2;
n 160     PyObject *tmp_assign_source_3; n
161     PyObject *tmp_iter_arg_1; 145     PyObject *tmp_iter_arg_1;
n 162     PyObject *tmp_outline_return_value_1; n
163     PyObject *tmp_return_value; 146     PyObject *tmp_return_value;
164     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 147     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
165     PyObject *tmp_value_name_1; 148     PyObject *tmp_value_name_1;
166     PyObject *tmp_value_name_2; 149     PyObject *tmp_value_name_2;
167     static struct Nuitka_FrameObject *cache_frame_b76412bf2829eb288f5aee0690760b57 = NULL; 150     static struct Nuitka_FrameObject *cache_frame_b76412bf2829eb288f5aee0690760b57 = NULL;
168 151
169     struct Nuitka_FrameObject *frame_b76412bf2829eb288f5aee0690760b57; 152     struct Nuitka_FrameObject *frame_b76412bf2829eb288f5aee0690760b57;
170 153
171     char const *type_description; 154     char const *type_description;
172     tmp_return_value = NULL; 155     tmp_return_value = NULL;
n 173     tmp_outline_return_value_1 = NULL; n
174 156
175     // Actual function code. 157     // Actual function code.
n 176     tmp_iter_arg_1 = const_xrange_0_3; n 158     tmp_iter_arg_1 = const_tuple_int_pos_1_int_pos_2_int_pos_3_tuple;
177     tmp_assign_source_2 = MAKE_ITERATOR( tmp_iter_arg_1 ); 159     tmp_assign_source_1 = MAKE_ITERATOR( tmp_iter_arg_1 );
178     assert( tmp_assign_source_2 != NULL ); 160     assert( tmp_assign_source_1 != NULL );
179     assert( tmp_genexpr_1__$0 == NULL );
180     tmp_genexpr_1__$0 = tmp_assign_source_2;
181  
182     // Tried code:
183     tmp_outline_return_value_1 = Nuitka_Generator_New(
184         __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context,
185         module___main__,
186         const_str_angle_genexpr,
187 #if PYTHON_VERSION >= 350
188         const_str_digest_57aac74124c55d29a6f122835861daff,
189 #endif
190         codeobj_e79428786c872b40b586ebec1b1ab40c,
191         1
192     );
193  
194     ((struct Nuitka_GeneratorObject *)tmp_outline_return_value_1)->m_closure[0] = PyCell_NEW0( tmp_genexpr_1__$0 );
195     assert( Py_SIZE( tmp_outline_return_value_1) >= 1 ); 
196  
197  
198     goto try_return_handler_1;
199     // tried codes exits in all cases
200     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
201     return NULL;
202     // Return handler code:
203     try_return_handler_1:;
204     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
205     Py_DECREF( tmp_genexpr_1__$0 );
206     tmp_genexpr_1__$0 = NULL;
207  
208     goto outline_result_1;
209     // End of try:
210     CHECK_OBJECT( (PyObject *)tmp_genexpr_1__$0 );
211     Py_DECREF( tmp_genexpr_1__$0 );
212     tmp_genexpr_1__$0 = NULL;
213  
214     // Return statement must have exited already.
215     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
216     return NULL;
217     outline_result_1:;
218     tmp_assign_source_1 = tmp_outline_return_value_1;
219     assert( var_gen == NULL ); 161     assert( var_gen == NULL );
220     var_gen = tmp_assign_source_1; 162     var_gen = tmp_assign_source_1;
221 163
222     // Tried code: 164     // Tried code:
223     MAKE_OR_REUSE_FRAME( cache_frame_b76412bf2829eb288f5aee0690760b57, codeobj_b76412bf2829eb288f5aee0690760b57, module___main__, sizeof(PyObject *)+sizeof(PyObject *) ); 165     MAKE_OR_REUSE_FRAME( cache_frame_b76412bf2829eb288f5aee0690760b57, codeobj_b76412bf2829eb288f5aee0690760b57, module___main__, sizeof(PyObject *)+sizeof(PyObject *) );
231 173
232     // Framed code: 174     // Framed code:
233     tmp_value_name_1 = var_gen; 175     tmp_value_name_1 = var_gen;
234 176
235     CHECK_OBJECT( tmp_value_name_1 ); 177     CHECK_OBJECT( tmp_value_name_1 );
n 236     tmp_assign_source_3 = ITERATOR_NEXT( tmp_value_name_1 ); n 178     tmp_assign_source_2 = ITERATOR_NEXT( tmp_value_name_1 );
237     if ( tmp_assign_source_3 == NULL ) 179     if ( tmp_assign_source_2 == NULL )
238     { 180     {
239         if ( !ERROR_OCCURRED() ) 181         if ( !ERROR_OCCURRED() )
240         { 182         {
241             exception_type = PyExc_StopIteration; 183             exception_type = PyExc_StopIteration;
242             Py_INCREF( exception_type ); 184             Py_INCREF( exception_type );
252         type_description = "oo"; 194         type_description = "oo";
253         exception_lineno = 29; 195         exception_lineno = 29;
254         goto frame_exception_exit_1; 196         goto frame_exception_exit_1;
255     } 197     }
256     assert( var_x == NULL ); 198     assert( var_x == NULL );
n 257     var_x = tmp_assign_source_3; n 199     var_x = tmp_assign_source_2;
258 200
259     tmp_value_name_2 = var_gen; 201     tmp_value_name_2 = var_gen;
260 202
261     if ( tmp_value_name_2 == NULL ) 203     if ( tmp_value_name_2 == NULL )
262     { 204     {
333 275
334     // Put the previous frame back on top. 276     // Put the previous frame back on top.
335     popFrameStack(); 277     popFrameStack();
336 278
337     // Return the error. 279     // Return the error.
n 338     goto try_except_handler_2; n 280     goto try_except_handler_1;
339 281
340     frame_no_exception_1:; 282     frame_no_exception_1:;
341 283
342     tmp_return_value = var_x; 284     tmp_return_value = var_x;
343 285
351         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 293         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
352         CHAIN_EXCEPTION( exception_value ); 294         CHAIN_EXCEPTION( exception_value );
353 295
354 296
355 297
n 356         goto try_except_handler_2; n 298         goto try_except_handler_1;
357     } 299     }
358 300
359     Py_INCREF( tmp_return_value ); 301     Py_INCREF( tmp_return_value );
n 360     goto try_return_handler_2; n 302     goto try_return_handler_1;
361     // tried codes exits in all cases 303     // tried codes exits in all cases
362     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 304     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
363     return NULL; 305     return NULL;
364     // Return handler code: 306     // Return handler code:
n 365     try_return_handler_2:; n 307     try_return_handler_1:;
366     Py_XDECREF( var_gen ); 308     Py_XDECREF( var_gen );
367     var_gen = NULL; 309     var_gen = NULL;
368 310
369     Py_XDECREF( var_x ); 311     Py_XDECREF( var_x );
370     var_x = NULL; 312     var_x = NULL;
371 313
372     goto function_return_exit; 314     goto function_return_exit;
373     // Exception handler code: 315     // Exception handler code:
n 374     try_except_handler_2:; n 316     try_except_handler_1:;
375     exception_keeper_type_1 = exception_type; 317     exception_keeper_type_1 = exception_type;
376     exception_keeper_value_1 = exception_value; 318     exception_keeper_value_1 = exception_value;
377     exception_keeper_tb_1 = exception_tb; 319     exception_keeper_tb_1 = exception_tb;
378     exception_keeper_lineno_1 = exception_lineno; 320     exception_keeper_lineno_1 = exception_lineno;
379     exception_type = NULL; 321     exception_type = NULL;
408     function_return_exit: 350     function_return_exit:
409 351
410     CHECK_OBJECT( tmp_return_value ); 352     CHECK_OBJECT( tmp_return_value );
411     assert( had_error || !ERROR_OCCURRED() ); 353     assert( had_error || !ERROR_OCCURRED() );
412     return tmp_return_value; 354     return tmp_return_value;
t 413   t
414 }
415  
416  
417  
418 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
419 struct __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_locals {
420     PyObject *var_x
421     PyObject *tmp_iter_value_0
422     PyObject *exception_type
423     PyObject *exception_value
424     PyTracebackObject *exception_tb
425     int exception_lineno
426     PyObject *exception_keeper_type_1;
427     PyObject *exception_keeper_value_1;
428     PyTracebackObject *exception_keeper_tb_1;
429     int exception_keeper_lineno_1;
430     PyObject *exception_keeper_type_2;
431     PyObject *exception_keeper_value_2;
432     PyTracebackObject *exception_keeper_tb_2;
433     int exception_keeper_lineno_2;
434     PyObject *tmp_assign_source_1;
435     PyObject *tmp_assign_source_2;
436     PyObject *tmp_expression_name_1;
437     PyObject *tmp_next_source_1;
438 };
439 #endif
440  
441 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
442 static PyObject *__main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator, PyObject *yield_return_value )
443 #else
444 static void __main__$$$function_1_calledRepeatedly$$$genexpr_1_genexpr_context( struct Nuitka_GeneratorObject *generator )
445 #endif
446 {
447     CHECK_OBJECT( (PyObject *)generator );
448     assert( Nuitka_Generator_Check( (PyObject *)generator ) );
449  
450     // Local variable initialization
451     PyObject *var_x = NULL;
452     PyObject *tmp_iter_value_0 = NULL;
453     PyObject *exception_type = NULL;
454     PyObject *exception_value = NULL;
455     PyTracebackObject *exception_tb = NULL;
456     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
457     PyObject *exception_keeper_type_1;
458     PyObject *exception_keeper_value_1;
459     PyTracebackObject *exception_keeper_tb_1;
460     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
461     PyObject *exception_keeper_type_2;
462     PyObject *exception_keeper_value_2;
463     PyTracebackObject *exception_keeper_tb_2;
464     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
465     PyObject *tmp_assign_source_1;
466     PyObject *tmp_assign_source_2;
467     PyObject *tmp_expression_name_1;
468     PyObject *tmp_next_source_1;
469     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
470     static struct Nuitka_FrameObject *cache_frame_generator = NULL;
471  
472     char const *type_description;
473  
474     // Dispatch to yield based on return label index:
475  
476  
477     // Actual function code.
478     // Tried code:
479     MAKE_OR_REUSE_FRAME( cache_frame_generator, codeobj_e79428786c872b40b586ebec1b1ab40c, module___main__, sizeof(void *)+sizeof(PyObject *) );
480     generator->m_frame = cache_frame_generator;
481  
482     // Mark the frame object as in use, ref count 1 will be up for reuse.
483     Py_INCREF( generator->m_frame );
484     assert( Py_REFCNT( generator->m_frame ) == 2 ); // Frame stack
485  
486 #if PYTHON_VERSION >= 340
487     generator->m_frame->m_frame.f_gen = (PyObject *)generator;
488 #endif
489  
490     Py_CLEAR( generator->m_frame->m_frame.f_back );
491  
492     generator->m_frame->m_frame.f_back = PyThreadState_GET()->frame;
493     Py_INCREF( generator->m_frame->m_frame.f_back );
494  
495     PyThreadState_GET()->frame = &generator->m_frame->m_frame;
496     Py_INCREF( generator->m_frame );
497  
498     Nuitka_Frame_MarkAsExecuting( generator->m_frame );
499  
500 #if PYTHON_VERSION >= 300
501     // Accept currently existing exception as the one to publish again when we
502     // yield or yield from.
503  
504     PyThreadState *thread_state = PyThreadState_GET();
505  
506     generator->m_frame->m_frame.f_exc_type = thread_state->exc_type;
507     if ( generator->m_frame->m_frame.f_exc_type == Py_None ) generator->m_frame->m_frame.f_exc_type = NULL;
508     Py_XINCREF( generator->m_frame->m_frame.f_exc_type );
509     generator->m_frame->m_frame.f_exc_value = thread_state->exc_value;
510     Py_XINCREF( generator->m_frame->m_frame.f_exc_value );
511     generator->m_frame->m_frame.f_exc_traceback = thread_state->exc_traceback;
512     Py_XINCREF( generator->m_frame->m_frame.f_exc_traceback );
513 #endif
514  
515     // Framed code:
516     // Tried code:
517     loop_start_1:;
518     if ( generator->m_closure[0] == NULL )
519     {
520         tmp_next_source_1 = NULL;
521     }
522     else
523     {
524         tmp_next_source_1 = PyCell_GET( generator->m_closure[0] );
525     }
526  
527     CHECK_OBJECT( tmp_next_source_1 );
528     tmp_assign_source_1 = ITERATOR_NEXT( tmp_next_source_1 );
529     if ( tmp_assign_source_1 == NULL )
530     {
531         if ( CHECK_AND_CLEAR_STOP_ITERATION_OCCURRED() )
532         {
533  
534             goto loop_end_1;
535         }
536         else
537         {
538  
539             FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
540             type_description = "No";
541             exception_lineno = 24;
542             goto try_except_handler_2;
543         }
544     }
545  
546     {
547         PyObject *old = tmp_iter_value_0;
548         tmp_iter_value_0 = tmp_assign_source_1;
549         Py_XDECREF( old );
550     }
551  
552     tmp_assign_source_2 = tmp_iter_value_0;
553  
554     CHECK_OBJECT( tmp_assign_source_2 );
555     {
556         PyObject *old = var_x;
557         var_x = tmp_assign_source_2;
558         Py_INCREF( var_x );
559         Py_XDECREF( old );
560     }
561  
562     tmp_expression_name_1 = var_x;
563  
564     CHECK_OBJECT( tmp_expression_name_1 );
565     Py_INCREF( tmp_expression_name_1 );
566     tmp_unused = GENERATOR_YIELD( generator, tmp_expression_name_1 );
567     if ( tmp_unused == NULL )
568     {
569         assert( ERROR_OCCURRED() );
570  
571         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
572  
573  
574         exception_lineno = 24;
575         type_description = "No";
576         goto try_except_handler_2;
577     }
578     if ( CONSIDER_THREADING() == false )
579     {
580         assert( ERROR_OCCURRED() );
581  
582         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
583  
584  
585         exception_lineno = 24;
586         type_description = "No";
587         goto try_except_handler_2;
588     }
589     goto loop_start_1;
590     loop_end_1:;
591     goto try_end_1;
592     // Exception handler code:
593     try_except_handler_2:;
594     exception_keeper_type_1 = exception_type;
595     exception_keeper_value_1 = exception_value;
596     exception_keeper_tb_1 = exception_tb;
597     exception_keeper_lineno_1 = exception_lineno;
598     exception_type = NULL;
599     exception_value = NULL;
600     exception_tb = NULL;
601     exception_lineno = 0;
602  
603     Py_XDECREF( tmp_iter_value_0 );
604     tmp_iter_value_0 = NULL;
605  
606     // Re-raise.
607     exception_type = exception_keeper_type_1;
608     exception_value = exception_keeper_value_1;
609     exception_tb = exception_keeper_tb_1;
610     exception_lineno = exception_keeper_lineno_1;
611  
612     goto frame_exception_exit_1;
613     // End of try:
614     try_end_1:;
615  
616     Nuitka_Frame_MarkAsNotExecuting( generator->m_frame );
617  
618 #if PYTHON_VERSION >= 300
619     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
620     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
621     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
622 #endif
623  
624     // Allow re-use of the frame again.
625     Py_DECREF( generator->m_frame );
626     goto frame_no_exception_1;
627  
628     frame_exception_exit_1:;
629  
630     // If it's not an exit exception, consider and create a traceback for it.
631     if ( !EXCEPTION_MATCH_GENERATOR( exception_type ) )
632     {
633         if ( exception_tb == NULL )
634         {
635             exception_tb = MAKE_TRACEBACK( generator->m_frame, exception_lineno );
636         }
637         else if ( exception_tb->tb_frame != &generator->m_frame->m_frame )
638         {
639             exception_tb = ADD_TRACEBACK( exception_tb, generator->m_frame, exception_lineno );
640         }
641  
642         Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)generator->m_frame, type_description ,NULL, var_x );
643  
644         // Release cached frame.
645         if ( generator->m_frame == cache_frame_generator )
646         {
647             Py_DECREF( generator->m_frame );
648         }
649         cache_frame_generator = NULL;
650  
651         assertFrameObject( generator->m_frame );
652     }
653  
654 #if PYTHON_VERSION >= 300
655     Py_CLEAR( generator->m_frame->m_frame.f_exc_type );
656     Py_CLEAR( generator->m_frame->m_frame.f_exc_value );
657     Py_CLEAR( generator->m_frame->m_frame.f_exc_traceback );
658 #endif
659  
660     Py_DECREF( generator->m_frame );
661     // Return the error.
662     goto try_except_handler_1;
663  
664     frame_no_exception_1:;
665  
666     goto try_end_2;
667     // Exception handler code:
668     try_except_handler_1:;
669     exception_keeper_type_2 = exception_type;
670     exception_keeper_value_2 = exception_value;
671     exception_keeper_tb_2 = exception_tb;
672     exception_keeper_lineno_2 = exception_lineno;
673     exception_type = NULL;
674     exception_value = NULL;
675     exception_tb = NULL;
676     exception_lineno = 0;
677  
678     Py_XDECREF( var_x );
679     var_x = NULL;
680  
681     // Re-raise.
682     exception_type = exception_keeper_type_2;
683     exception_value = exception_keeper_value_2;
684     exception_tb = exception_keeper_tb_2;
685     exception_lineno = exception_keeper_lineno_2;
686  
687     goto function_exception_exit;
688     // End of try:
689     try_end_2:;
690     Py_XDECREF( tmp_iter_value_0 );
691     tmp_iter_value_0 = NULL;
692  
693     Py_XDECREF( var_x );
694     var_x = NULL;
695  
696  
697 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
698     return NULL;
699 #else
700     generator->m_yielded = NULL;
701     return;
702 #endif
703  
704     function_exception_exit:
705     assert( exception_type );
706     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
707  
708 #if _NUITKA_EXPERIMENTAL_GENERATOR_GOTO
709     return NULL;
710 #else
711     generator->m_yielded = NULL;
712     return;
713 #endif
714 355
715 } 356 }
716 357
717 358
718 359