.. title: Construct GeneratorUsage
.. tags: 310_develop_steady_vs_main,310_factory_steady_vs_develop,38_develop_steady_vs_main,38_factory_steady_vs_develop,27_develop_steady_vs_main,27_factory_steady_vs_develop
.. date: 03/28/2024, 10:20:18
.. contents::
Performance Diagrams
====================
.. chart:: Bar
:title: 'Construct GeneratorUsage'
:x_labels: ['CPython 3.10', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)']
'Ticks', [25309066, 5799858, 5800139, 5799914]
.. chart:: Bar
:title: 'Construct GeneratorUsage'
:x_labels: ['CPython 3.8', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)']
'Ticks', [23790551, 5800000, 5799985, 5799874]
.. chart:: Bar
:title: 'Construct GeneratorUsage'
:x_labels: ['CPython 2.7', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)']
'Ticks', [34549299, 7450000, 7450000, 7450000]
Source Code with Construct
==========================
.. code-block:: python
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
=============================
.. code-block:: python
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
===========================
.. raw:: html
|
|
| | | |
| gen = generator() | | gen = generator() |
| | | |
| x = next(gen) | | x = next(gen) |
| # construct_begin | | # construct_begin |
t | next(gen) | t | |
| # construct_end | | |
| | | |
| return x | | return x |
| | | |
| | | |
| for x in itertools.repeat(None, 50000): | | for x in itertools.repeat(None, 50000): |
Context Diff of Generated Code
==============================
.. raw:: html
|
|
| NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; | | NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; |
| PyObject *exception_type = NULL; | | PyObject *exception_type = NULL; |
| PyObject *exception_value = NULL; | | PyObject *exception_value = NULL; |
| PyTracebackObject *exception_tb = NULL; | | PyTracebackObject *exception_tb = NULL; |
| NUITKA_MAY_BE_UNUSED int exception_lineno = 0; | | NUITKA_MAY_BE_UNUSED int exception_lineno = 0; |
n | NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; | n | |
| static struct Nuitka_FrameObject *cache_frame_fdeae296bf2888a1f42e64e5b0ec9394 = NULL; | | static struct Nuitka_FrameObject *cache_frame_fdeae296bf2888a1f42e64e5b0ec9394 = NULL; |
| PyObject *tmp_return_value = NULL; | | PyObject *tmp_return_value = NULL; |
| PyObject *exception_keeper_type_1; | | PyObject *exception_keeper_type_1; |
| PyObject *exception_keeper_value_1; | | PyObject *exception_keeper_value_1; |
| PyTracebackObject *exception_keeper_tb_1; | | PyTracebackObject *exception_keeper_tb_1; |
| exception_lineno = 16; | | exception_lineno = 16; |
| goto frame_exception_exit_1; | | goto frame_exception_exit_1; |
| } | | } |
| assert(var_x == NULL); | | assert(var_x == NULL); |
| var_x = tmp_assign_source_3; | | var_x = tmp_assign_source_3; |
n | } | n | |
| { | | |
| PyObject *tmp_value_value_2; | | |
| PyObject *tmp_next_value_1; | | |
| CHECK_OBJECT(var_gen); | | |
| tmp_value_value_2 = var_gen; | | |
| tmp_next_value_1 = ITERATOR_NEXT(tmp_value_value_2); | | |
| if (tmp_next_value_1 == NULL) { | | |
| if (!HAS_ERROR_OCCURRED(tstate)) { | | |
| exception_type = PyExc_StopIteration; | | |
| Py_INCREF(exception_type); | | |
| exception_value = NULL; | | |
| exception_tb = NULL; | | |
| } else { | | |
| FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | | |
| } | | |
| | | |
| | | |
| type_description_1 = "ooo"; | | |
| exception_lineno = 18; | | |
| goto frame_exception_exit_1; | | |
| } | | |
| Py_DECREF(tmp_next_value_1); | | |
| } | | } |
| | | |
| | | |
| // Put the previous frame back on top. | | // Put the previous frame back on top. |
| popFrameStack(tstate); | | popFrameStack(tstate); |
| CHECK_OBJECT(var_generator); | | CHECK_OBJECT(var_generator); |
| Py_DECREF(var_generator); | | Py_DECREF(var_generator); |
| var_generator = NULL; | | var_generator = NULL; |
| Py_XDECREF(var_gen); | | Py_XDECREF(var_gen); |
| var_gen = NULL; | | var_gen = NULL; |
t | Py_XDECREF(var_x); | t | |
| var_x = NULL; | | |
| // Re-raise. | | // Re-raise. |
| exception_type = exception_keeper_type_1; | | exception_type = exception_keeper_type_1; |
| exception_value = exception_keeper_value_1; | | exception_value = exception_keeper_value_1; |
| exception_tb = exception_keeper_tb_1; | | exception_tb = exception_keeper_tb_1; |
| exception_lineno = exception_keeper_lineno_1; | | exception_lineno = exception_keeper_lineno_1; |