Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-96793: Implement PEP 479 in bytecode.#99006

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 8 commits intopython:mainfromfaster-cpython:pep-479-bytecode
Nov 3, 2022

Conversation

markshannon
Copy link
Member

@markshannonmarkshannon commentedNov 2, 2022
edited by bedevere-bot
Loading

In order to specialize iteration over generators and send to coroutines we need to remove the pre- and post checks from the C wrappers.
The pre-checks are largely eliminated by the the compiler and specialization.
The post-checks need to be handled in bytecode.
To do that, we wrap the generator body in atry: ... except StopIteration: ... which converts theStopIteration into aRuntimeError.

I initially did this entirely in bytecode, but it adds alot of bulk to the bytecode.

The newSTOPITERATION_ERROR instruction should only be temporary:#99005

@@ -346,7 +346,7 @@ def make_tracer():
return Tracer()

def compare_events(self, line_offset, events, expected_events):
events = [(l - line_offset, e) for (l, e) in events]
events = [(l - line_offset if l is not None else None, e) for (l, e) in events]
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I introduced for debugging this PR. It is no longer strictly necessary, but it gives nicer output when tests fail.


static int
wrap_in_stopiteration_handler(struct compiler *c)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I wonder if this is not wrapping too much, like the instructions that deal with the function's arguments and annotations?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Annotations are executed in the enclosing scope, as are defaults. So there is no problem there.
MAKE_CELL andRETURN_GENERATOR instructions are inserted in the back-end so happen after this.

Copy link
Member

@iritkatrieliritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@markshannon@iritkatriel@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp