René's URL Explorer Experiment


Title: gh-158407: Restore the C fast path for anext() by leandrodamascena · Pull Request #158964 · python/cpython · GitHub

Open Graph Title: gh-158407: Restore the C fast path for anext() by leandrodamascena · Pull Request #158964 · python/cpython

X Title: gh-158407: Restore the C fast path for anext() by leandrodamascena · Pull Request #158964 · python/cpython

Description: This restores the C implementation of anext() for the common one-argument case, calling the am_anext slot directly as before gh-157361. The two-argument form keeps using the Python coroutine from _pybuiltins, so the call graph improvement from gh-157361 still applies there. This follows the approach I proposed in #158407. I'm happy to change direction if there's a better way, especially with aiter() in #157687 in mind. Local results (release build, ns per item): case main this PR anext(async_gen) 211 140 anext(class_iter) 156 138 anext(async_gen, default) 297 239 anext(class_iter, default) 218 233 async for (control) 126 126 The one case that gets a bit slower is anext() with a default on a Python class iterator, since the coroutine is now called from C instead of from Python. Two tests change as a result: inspect.signature(anext) is back to unsupported (as in 3.15), and the traceback test only checks the coroutine frame, since the TypeError now comes from C. Issue: gh-158407

Open Graph Description: This restores the C implementation of anext() for the common one-argument case, calling the am_anext slot directly as before gh-157361. The two-argument form keeps using the Python coroutine from _...

X Description: This restores the C implementation of anext() for the common one-argument case, calling the am_anext slot directly as before gh-157361. The two-argument form keeps using the Python coroutine from _...

Opengraph URL: https://github.com/python/cpython/pull/158964

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:67f557be-625d-9485-af50-0c4b6a9b89d6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA4C6:F8C5C:1229179:16D06C6:6B023F57
html-safe-nonce90298695cd94c7d325196044229f574b901bd38e2a4bd30c83c1eaa384cae972
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEM2OkY4QzVDOjEyMjkxNzk6MTZEMDZDNjo2QjAyM0Y1NyIsInZpc2l0b3JfaWQiOiI0NzY4OTQ3Njk1MTY5NzE2MDU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7ec671191c9f14eef64aee9041a43d6170499d061e200bed6496a10c38cb9098
hovercard-subject-tagpull_request:4772373421
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/158964/files
twitter:imagehttps://avatars.githubusercontent.com/u/4295173?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4295173?s=400&v=4
og:image:altThis restores the C implementation of anext() for the common one-argument case, calling the am_anext slot directly as before gh-157361. The two-argument form keeps using the Python coroutine from _...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/158964/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F158964%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F158964%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/158964/files
Reloadhttps://github.com/python/cpython/pull/158964/files
Reloadhttps://github.com/python/cpython/pull/158964/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
leandrodamascenahttps://github.com/leandrodamascena
python:mainhttps://github.com/python/cpython/tree/main
leandrodamascena:gh-158407-anexthttps://github.com/leandrodamascena/cpython/tree/gh-158407-anext
Conversation 2 https://github.com/python/cpython/pull/158964
Commits 2 https://github.com/python/cpython/pull/158964/commits
Checks 51 https://github.com/python/cpython/pull/158964/checks
Files changed https://github.com/python/cpython/pull/158964/files
Please reload this pagehttps://github.com/python/cpython/pull/158964/files
gh-158407: Restore the C fast path for anext() https://github.com/python/cpython/pull/158964/files#top
Show all changes 2 commits https://github.com/python/cpython/pull/158964/files
8a8a809 gh-158407: Restore the C fast path for anext() leandrodamascena Oct 7, 2026 https://github.com/python/cpython/pull/158964/commits/8a8a8094d183f78c2b6e999d42d06fd6dc62a1fc
af6143d Merge branch 'main' into gh-158407-anext leandrodamascena Oct 7, 2026 https://github.com/python/cpython/pull/158964/commits/af6143d6df2f6f60b128529ba8a1aea89433b0c7
Clear filters https://github.com/python/cpython/pull/158964/files
Please reload this pagehttps://github.com/python/cpython/pull/158964/files
Please reload this pagehttps://github.com/python/cpython/pull/158964/files
pycore_interp_structs.h https://github.com/python/cpython/pull/158964/files#diff-6075b6142803c1eccc213aa150704fd639443c65311d5999f69a5ea77cb76756
_pybuiltins.py https://github.com/python/cpython/pull/158964/files#diff-490203e0638be1c25e2b57c9409fa62bb554625b066ce39c9a0a5731a44ff674
test_asyncgen.py https://github.com/python/cpython/pull/158964/files#diff-1da5f0220b91e20c669b0e63724b978d4cf603373c850fbdc705abb2d5937f40
test_inspect.py https://github.com/python/cpython/pull/158964/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
2026-09-29-18-00-00.gh-issue-158407.anxtFst.rst https://github.com/python/cpython/pull/158964/files#diff-987fe7a1d2c67825b30439b06cca278ccb9a0ed7ef07928a1cb76825dacd1fe1
bltinmodule.c https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
bltinmodule.c.h https://github.com/python/cpython/pull/158964/files#diff-a4b4bbe4bcd5f70f9cbf9fb324779deb3c774ab38683ebc3cad83f03920070c5
pystate.c https://github.com/python/cpython/pull/158964/files#diff-7ac11e526f79b42d6ea9d3592cb99da46775640c69fa5510f4a6de87cced7141
Include/internal/pycore_interp_structs.hhttps://github.com/python/cpython/pull/158964/files#diff-6075b6142803c1eccc213aa150704fd639443c65311d5999f69a5ea77cb76756
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Include/internal/pycore_interp_structs.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-6075b6142803c1eccc213aa150704fd639443c65311d5999f69a5ea77cb76756
https://github.com/python/cpython/pull/158964/files#diff-6075b6142803c1eccc213aa150704fd639443c65311d5999f69a5ea77cb76756
Lib/_pybuiltins.pyhttps://github.com/python/cpython/pull/158964/files#diff-490203e0638be1c25e2b57c9409fa62bb554625b066ce39c9a0a5731a44ff674
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Lib/_pybuiltins.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-490203e0638be1c25e2b57c9409fa62bb554625b066ce39c9a0a5731a44ff674
Lib/test/test_asyncgen.pyhttps://github.com/python/cpython/pull/158964/files#diff-1da5f0220b91e20c669b0e63724b978d4cf603373c850fbdc705abb2d5937f40
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Lib/test/test_asyncgen.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-1da5f0220b91e20c669b0e63724b978d4cf603373c850fbdc705abb2d5937f40
https://github.com/python/cpython/pull/158964/files#diff-1da5f0220b91e20c669b0e63724b978d4cf603373c850fbdc705abb2d5937f40
https://github.com/python/cpython/pull/158964/files#diff-1da5f0220b91e20c669b0e63724b978d4cf603373c850fbdc705abb2d5937f40
Lib/test/test_inspect/test_inspect.pyhttps://github.com/python/cpython/pull/158964/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Lib/test/test_inspect/test_inspect.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
https://github.com/python/cpython/pull/158964/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
Misc/NEWS.d/next/Core_and_Builtins/2026-09-29-18-00-00.gh-issue-158407.anxtFst.rsthttps://github.com/python/cpython/pull/158964/files#diff-987fe7a1d2c67825b30439b06cca278ccb9a0ed7ef07928a1cb76825dacd1fe1
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Misc/NEWS.d/next/Core_and_Builtins/2026-09-29-18-00-00.gh-issue-158407.anxtFst.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L243
Python/bltinmodule.chttps://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Python/bltinmodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
https://github.com/python/cpython/pull/158964/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
Python/clinic/bltinmodule.c.hhttps://github.com/python/cpython/pull/158964/files#diff-a4b4bbe4bcd5f70f9cbf9fb324779deb3c774ab38683ebc3cad83f03920070c5
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Python/clinic/bltinmodule.c.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/158964/files
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L319
Python/pystate.chttps://github.com/python/cpython/pull/158964/files#diff-7ac11e526f79b42d6ea9d3592cb99da46775640c69fa5510f4a6de87cced7141
View file https://github.com/leandrodamascena/cpython/blob/af6143d6df2f6f60b128529ba8a1aea89433b0c7/Python/pystate.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158964/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158964/files#diff-7ac11e526f79b42d6ea9d3592cb99da46775640c69fa5510f4a6de87cced7141
https://github.com/python/cpython/pull/158964/files#diff-7ac11e526f79b42d6ea9d3592cb99da46775640c69fa5510f4a6de87cced7141
Please reload this pagehttps://github.com/python/cpython/pull/158964/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.