FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-143732: SEND specialization by markshannon · Pull Request #148963 · python/cpython · GitHub

/ cpython Public

GH-143732: SEND specialization - #148963

Merged
markshannon merged 11 commits into
python:mainfrom
markshannon:send-specialization
May 5, 2026
Merged

GH-143732: SEND specialization#148963
markshannon merged 11 commits into
python:mainfrom
markshannon:send-specialization

Conversation

markshannon commented Apr 24, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Adds 2 new specialized instructions:

  • SEND_VIRTUAL for sends to virtual iterators e.g lists and tuples
  • SEND_ASYNC_GEN for sends to async generators

Also, tweaks FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards

This is aimed more at JIT coverage, especially ensuring that we can trace through SEND instructions, than interpreter performance.

Performance is broadly neutral, but with improvements of 4-6% on the async_generators benchmark.

* SEND_VIRTUAL: for sends to virtual iterators e.g lists and tuples
* SEND_ASYNC_GEN: for sends to async generators

Tweak FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards
Comment thread Tools/cases_generator/analyzer.py Outdated
"_PyStolenTuple_Free",
"PyObject_GC_UnTrack",
"_PyErr_ExceptionMatches",
"CALL_TP_ITERITEM",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think this is right?

markshannon Apr 27, 2026
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It is correct in the normal build, but I'll need to exclude lists in the free-threading build.

markshannon Apr 27, 2026
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Special casing the free-threaded build is too messy, so I've removed this from the whitelist instead.

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, just two questions, feel free to merge after addressing them.

Comment thread Objects/genobject.c
0, /* am_anext */
0, /* am_send */
.am_await = PyObject_SelfIter,
.am_send = _PyAsyncGenASend_Send,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why this change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Otherwise, the send needs to go through a call to the send method. I don't know why this wasn't implemented before.

Comment thread Python/ceval_macros.h Outdated
(PyLongObject *)PyStackRef_AsPyObjectBorrow(right)); \
}

#define CALL_TP_ITERITEM(ITER, INDEX) \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I know this is to make it non-escaping to the analyzer, but it would be clearer if you said CALL_TP_ITERITEM_NO_ESCAPE or something.

markshannon May 5, 2026
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I dropped the special meaning, to avoid problems with the free-threading build.
I'll just remove the macro, as it isn't doing anything useful any more.

I dropped it for the SAI. I'll update the name as you suggest for the JIT.

read-the-docs-community Bot commented May 5, 2026
edited
Loading

Copy link
Copy Markdown

markshannon merged commit 70bd1c2 into python:main May 5, 2026
84 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL