Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111354: Simplify _PyGen_yf by moving some of its work to the compiler and frame state #111648

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ iterations of the loop.
oparg set to be the exception block depth, for efficient closing of generators.

.. versionchanged:: 3.13
this opcode no longer has an oparg
oparg is ``1`` if this instruction is part of a yield-from or await, and ``0``
otherwise.

.. opcode:: SETUP_ANNOTATIONS

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,8 @@ Others
CPython bytecode changes
========================

* ``YIELD_VALUE`` no longer has an oparg. The oparg of ``RESUME`` was
* The oparg of ``YIELD_VALUE`` is now ``1`` if the yield is part of a
yield-from or await, and ``0`` otherwise. The oparg of ``RESUME`` was
changed to add a bit indicating whether the except-depth is 1, which
is needed to optimize closing of generators.
(Contributed by Irit Katriel in :gh:`111354`.)
Expand Down
7 changes: 5 additions & 2 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
/* other API */

typedef enum _framestate {
FRAME_CREATED = -2,
FRAME_SUSPENDED = -1,
FRAME_CREATED = -3,
FRAME_SUSPENDED = -2,
FRAME_SUSPENDED_YIELD_FROM = -1,
FRAME_EXECUTING = 0,
FRAME_COMPLETED = 1,
FRAME_CLEARED = 4
} PyFrameState;

#define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM)

enum _frameowner {
FRAME_OWNED_BY_THREAD = 0,
FRAME_OWNED_BY_GENERATOR = 1,
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 75 additions & 75 deletions Include/opcode_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 75 additions & 75 deletions Lib/_opcode_metadata.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading