Construct GeneratorUsage
Performance Diagrams
Source Code with Construct
return x for x in itertools.repeat(None, 50000): calledRepeatedly() print("OK.") # Python test originally created or extracted from other peoples work. The # parts from me are licensed as below. It is at least Free Software where # it's copied from other people. In these cases, that will normally be # indicated. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
Source Code without Construct
return x for x in itertools.repeat(None, 50000): calledRepeatedly() print("OK.") # Python test originally created or extracted from other peoples work. The # parts from me are licensed as below. It is at least Free Software where # it's copied from other people. In these cases, that will normally be # indicated. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
Context Diff of Source Code
Construct | Baseline | ||||
---|---|---|---|---|---|
13 | 13 | ||||
14 | gen = generator() | 14 | gen = generator() | ||
15 | 15 | ||||
16 | x = next(gen) | 16 | x = next(gen) | ||
17 | # construct_begin | 17 | # construct_begin | ||
t | 18 | next(gen) | t | 18 | |
19 | # construct_end | 19 | |||
20 | 20 | ||||
21 | return x | 21 | return x | ||
22 | 22 | ||||
23 | 23 | ||||
24 | for x in itertools.repeat(None, 50000): | 24 | for x in itertools.repeat(None, 50000): |
Context Diff of Generated Code
Construct | Baseline | ||||
---|---|---|---|---|---|
117 | NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; | 117 | NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; | ||
118 | PyObject *exception_type = NULL; | 118 | PyObject *exception_type = NULL; | ||
119 | PyObject *exception_value = NULL; | 119 | PyObject *exception_value = NULL; | ||
120 | PyTracebackObject *exception_tb = NULL; | 120 | PyTracebackObject *exception_tb = NULL; | ||
121 | NUITKA_MAY_BE_UNUSED int exception_lineno = 0; | 121 | NUITKA_MAY_BE_UNUSED int exception_lineno = 0; | ||
n | 122 | NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; | n | ||
123 | static struct Nuitka_FrameObject *cache_frame_0e3929eae9272b58ded6c92efadf96a1 = NULL; | 122 | static struct Nuitka_FrameObject *cache_frame_0e3929eae9272b58ded6c92efadf96a1 = NULL; | ||
124 | PyObject *tmp_return_value = NULL; | 123 | PyObject *tmp_return_value = NULL; | ||
125 | PyObject *exception_keeper_type_1; | 124 | PyObject *exception_keeper_type_1; | ||
126 | PyObject *exception_keeper_value_1; | 125 | PyObject *exception_keeper_value_1; | ||
127 | PyTracebackObject *exception_keeper_tb_1; | 126 | PyTracebackObject *exception_keeper_tb_1; | ||
206 | exception_lineno = 16; | 205 | exception_lineno = 16; | ||
207 | goto frame_exception_exit_1; | 206 | goto frame_exception_exit_1; | ||
208 | } | 207 | } | ||
209 | assert(var_x == NULL); | 208 | assert(var_x == NULL); | ||
210 | var_x = tmp_assign_source_3; | 209 | var_x = tmp_assign_source_3; | ||
n | 211 | } | n | ||
212 | { | ||||
213 | PyObject *tmp_value_value_2; | ||||
214 | PyObject *tmp_next_value_1; | ||||
215 | CHECK_OBJECT(var_gen); | ||||
216 | tmp_value_value_2 = var_gen; | ||||
217 | tmp_next_value_1 = ITERATOR_NEXT(tmp_value_value_2); | ||||
218 | if (tmp_next_value_1 == NULL) { | ||||
219 | if (!HAS_ERROR_OCCURRED(tstate)) { | ||||
220 | exception_type = PyExc_StopIteration; | ||||
221 | Py_INCREF(exception_type); | ||||
222 | exception_value = NULL; | ||||
223 | exception_tb = NULL; | ||||
224 | } else { | ||||
225 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | ||||
226 | } | ||||
227 | |||||
228 | |||||
229 | type_description_1 = "ooo"; | ||||
230 | exception_lineno = 18; | ||||
231 | goto frame_exception_exit_1; | ||||
232 | } | ||||
233 | Py_DECREF(tmp_next_value_1); | ||||
234 | } | 210 | } | ||
235 | 211 | ||||
236 | 212 | ||||
237 | // Put the previous frame back on top. | 213 | // Put the previous frame back on top. | ||
238 | popFrameStack(tstate); | 214 | popFrameStack(tstate); | ||
307 | CHECK_OBJECT(var_generator); | 283 | CHECK_OBJECT(var_generator); | ||
308 | Py_DECREF(var_generator); | 284 | Py_DECREF(var_generator); | ||
309 | var_generator = NULL; | 285 | var_generator = NULL; | ||
310 | Py_XDECREF(var_gen); | 286 | Py_XDECREF(var_gen); | ||
311 | var_gen = NULL; | 287 | var_gen = NULL; | ||
t | 312 | Py_XDECREF(var_x); | t | ||
313 | var_x = NULL; | ||||
314 | // Re-raise. | 288 | // Re-raise. | ||
315 | exception_type = exception_keeper_type_1; | 289 | exception_type = exception_keeper_type_1; | ||
316 | exception_value = exception_keeper_value_1; | 290 | exception_value = exception_keeper_value_1; | ||
317 | exception_tb = exception_keeper_tb_1; | 291 | exception_tb = exception_keeper_tb_1; | ||
318 | exception_lineno = exception_keeper_lineno_1; | 292 | exception_lineno = exception_keeper_lineno_1; |