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-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

Merged
markshannon merged 4 commits intopython:mainfromfaster-cpython:fix-103488
Apr 13, 2023

Conversation

markshannon
Copy link
Member

@markshannonmarkshannon commentedApr 13, 2023
edited by bedevere-bot
Loading

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 toprev_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.

sunmy2019 reacted with thumbs up emoji
@@ -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;
Copy link
Member

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?

Copy link
MemberAuthor

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.

Copy link
MemberAuthor

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

@Eclips4
Copy link
Member

Also, this PR fixes#101914, output from pylint usingexample:

(venv) eclips4@HOME-PC:~/ide/cpython$ pylint test.py************* Module testtest.py:1:0: C0114: Missing module docstring (missing-module-docstring)test.py:1:4: E0602: Undefined variable 'b' (undefined-variable)test.py:2:0: E0602: Undefined variable 'func' (undefined-variable)------------------------------------------------------------------Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

@mdboom can you confirm that? =)

@markshannonmarkshannon merged commitefb8a25 intopython:mainApr 13, 2023
carljm added a commit to carljm/cpython that referenced this pull requestApr 13, 2023
* 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)
@mdboom
Copy link
Contributor

@mdboom can you confirm that? =)

Yes, confirmed. I closed#101914 as a result.

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.

5 participants
@markshannon@Eclips4@mdboom@iritkatriel@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp