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-103488: Use return-offset, not yield-offset.#103502
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
@@ -1724,6 +1727,7 @@ dummy_func( | |||
STACK_SHRINK(shrink_stack); | |||
new_frame->localsplus[0] = owner; | |||
JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); | |||
frame->return_offset = 0; |
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.
What are the rules about when this needs to be 0ed and when it doesn't?
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.
return_offset
is only meaningful to the callee, so it needs to be set in anyCALL
(to a Python function) orSEND
(to a coroutine or generator).
If there is no callee, then it is meaningless.
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've added a comment in pycore_frame.h
Also, this PR fixes#101914, output from pylint usingexample:
@mdboom can you confirm that? =) |
* main:pythongh-103479: [Enum] require __new__ to be considered a data type (pythonGH-103495)pythongh-103365: [Enum] STRICT boundary corrections (pythonGH-103494)pythonGH-103488: Use return-offset, not yield-offset. (pythonGH-103502)pythongh-103088: Fix test_venv error message to avoid bytes/str warning (pythonGH-103500)pythonGH-103082: Turn on branch events for FOR_ITER instructions. (python#103507)pythongh-102978: Fix mock.patch function signatures for class and staticmethod decorators (python#103228)pythongh-103462: Ensure SelectorSocketTransport.writelines registers a writer when data is still pending (python#103463)pythongh-95299: Rework test_cppext.py to not invoke setup.py directly (python#103316)
Uh oh!
There was an error while loading.Please reload this page.
This ensures that the callers instruction pointer is correct when sending to a generator or coroutine.
This is necessary for exception handling, and nice for debuggers and profilers.
Instead of returning to
prev_instr +1
and yielding toprev_instr - yield_offset + 1
we now return toprev_instr + return_offset + 1
and yield toprev_instr +1
.These are equivalent unless there is an exception, or when introspecting the stack.
Since call/returns are more common than send/yields this will be a tiny bit slower than main, but reverting to the 3.11 approach would alot slower.
Compared to the 3.11, this makes call/returns a few percent slower and send/yields an order of magnitude faster.