Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -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] |
There was a problem hiding this comment.
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) | ||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Uh oh!
There was an error while loading.Please reload this page.
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 a
try: ... except StopIteration: ...
which converts theStopIteration
into aRuntimeError
.I initially did this entirely in bytecode, but it adds alot of bulk to the bytecode.
The new
STOPITERATION_ERROR
instruction should only be temporary:#99005for gen():
, and awaiting coroutines,await coro()
#96793