René's URL Explorer Experiment


Title: Implement `anext` and `aiter` in pure Python · Issue #157361 · python/cpython · GitHub

Open Graph Title: Implement `anext` and `aiter` in pure Python · Issue #157361 · python/cpython

X Title: Implement `anext` and `aiter` in pure Python · Issue #157361 · python/cpython

Description: Feature or enhancement Feature or enhancement I propose to implement anext() and aiter() in Python instead of C, compiled at interpreter startup and copied into builtins. This removes the private anext_awaitable, async_callable_iterator ...

Open Graph Description: Feature or enhancement Feature or enhancement I propose to implement anext() and aiter() in Python instead of C, compiled at interpreter startup and copied into builtins. This removes the private a...

X Description: Feature or enhancement Feature or enhancement I propose to implement anext() and aiter() in Python instead of C, compiled at interpreter startup and copied into builtins. This removes the private a...

Opengraph URL: https://github.com/python/cpython/issues/157361

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement `anext` and `aiter` in pure Python","articleBody":"# Feature or enhancement\n\n## Feature or enhancement\n\nI propose to implement `anext()` and `aiter()` in Python instead of C, compiled at interpreter startup and copied into builtins. This removes the private `anext_awaitable`, `async_callable_iterator` and `async_callable_iterator_awaitable` types.\n\n`anext(it, default)` becomes a plain coroutine that awaits `type(it).__anext__(it)` and converts `StopAsyncIteration` into the default. The callable form of `aiter()` (gh-64862) becomes a small class with `async def __anext__` that calls and awaits the callable and turns the sentinel or `stop_exception` into `StopAsyncIteration`. Semantics stay the same.\n\nThe motivation is #157032 and #157044: the C awaitables break the asyncio await graph. `capture_call_graph` walks `cr_await`/`ag_await`, and these types have neither, so the graph stops at the frame calling `anext(it, default)` or iterating `aiter(callable, sentinel)` and hides where the task is actually suspended. This would fix #157032, #157044 without any special casing. \n\n\nRepro with a class-based async iterator:\n\n```python\nimport asyncio\n\nasync def fetch():\n    await asyncio.sleep(10)\n\nclass AIter:\n    def __aiter__(self): return self\n    async def __anext__(self):\n        await fetch()\n        return 1\n\nasync def consumer():\n    await anext(AIter(), None)\n\nasync def main():\n    t = asyncio.create_task(consumer(), name=\"consumer\")\n    for _ in range(3):\n        await asyncio.sleep(0)\n    asyncio.print_call_graph(t)\n    t.cancel()\n\nasyncio.run(main())\n```\n\nBefore:\n\n```\n* Task(name='consumer', id=0x10a42c7d0)\n  + Call stack:\n  |   File 'demo.py', line 13, in async consumer()\n```\n\nAfter:\n\n```\n* Task(name='consumer', id=0x108959b80)\n  + Call stack:\n  |   File 'Lib/asyncio/tasks.py', line 707, in async sleep()\n  |   File 'demo.py', line 4, in async fetch()\n  |   File 'demo.py', line 9, in async AIter.__anext__()\n  |   File '\u003cbuiltins>', line 26, in async _anext_with_default()\n  |   File 'demo.py', line 13, in async consumer()\n```\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157362\n* gh-157687\n* gh-159867\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/kumaraditya303","@type":"Person","name":"kumaraditya303"},"datePublished":"2026-09-12T10:30:18Z","url":"https://github.com/python/cpython/issues/157361"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:24f9064f-c91b-e411-7fa8-fa77620c85d3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA802:E9D16:3C2365D:4C2F299:6B023A98
html-safe-nonceaa033a3b85386c7a5e3f42974d1fdb897ada036925e8bcce86fdbfe9f9e6241f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODAyOkU5RDE2OjNDMjM2NUQ6NEMyRjI5OTo2QjAyM0E5OCIsInZpc2l0b3JfaWQiOiI4NzA0NjUxMjY3NjAwOTU2MDU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac5d25e31eafb520a63470a8508d881a71163ae1dfa4964d4be02ba825647cce54
hovercard-subject-tagissue:5432747176
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/157361/issue_layout
twitter:imagehttps://opengraph.githubassets.com/11ec0515315208e892582f52159c29e934fac0dd5ce5e8c12320b005bad8ceae/python/cpython/issues/157361
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/11ec0515315208e892582f52159c29e934fac0dd5ce5e8c12320b005bad8ceae/python/cpython/issues/157361
og:image:altFeature or enhancement Feature or enhancement I propose to implement anext() and aiter() in Python instead of C, compiled at interpreter startup and copied into builtins. This removes the private a...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekumaraditya303
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
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
disable-turbofalse
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
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/157361#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F157361
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%2Fissues%2F157361
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/157361
Reloadhttps://github.com/python/cpython/issues/157361
Reloadhttps://github.com/python/cpython/issues/157361
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
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/157361
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/157361
Implement anext and aiter in pure Pythonhttps://github.com/python/cpython/issues/157361#top
https://github.com/kumaraditya303
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issue-5432747176
gh-64862https://github.com/python/cpython/issues/64862
#157032https://github.com/python/cpython/issues/157032
#157044https://github.com/python/cpython/issues/157044
#157032https://github.com/python/cpython/issues/157032
#157044https://github.com/python/cpython/issues/157044
gh-157361: Implement anext() in Python instead of C #157362https://github.com/python/cpython/pull/157362
gh-157361: Implement aiter() in Python instead of C #157687https://github.com/python/cpython/pull/157687
gh-157361: Add What's New entry for anext() and aiter() in Python #159867https://github.com/python/cpython/pull/159867
kumaraditya303https://github.com/kumaraditya303
on Sep 12, 2026https://github.com/python/cpython/issues/157361#event-31018148299
kumaraditya303https://github.com/kumaraditya303
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
on Sep 12, 2026https://github.com/python/cpython/issues/157361#event-31018148749
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Sep 12, 2026https://github.com/python/cpython/issues/157361#event-31018149702
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Sep 12, 2026https://github.com/python/cpython/issues/157361
picnixzhttps://github.com/picnixz
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Sep 12, 2026https://github.com/python/cpython/issues/157361#event-31018321263
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issuecomment-5645380155
https://github.com/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issuecomment-5645397796
#157362https://github.com/python/cpython/pull/157362
https://github.com/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issuecomment-5645424115
picnixzhttps://github.com/picnixz
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Sep 12, 2026https://github.com/python/cpython/issues/157361#event-31018760452
https://github.com/deadlovelll
deadlovelllhttps://github.com/deadlovelll
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issuecomment-5647920715
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Sep 12, 2026https://github.com/python/cpython/issues/157361#issuecomment-5647958364
https://github.com/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Sep 13, 2026https://github.com/python/cpython/issues/157361#issuecomment-5650819545
https://github.com/deadlovelll
deadlovelllhttps://github.com/deadlovelll
on Sep 13, 2026https://github.com/python/cpython/issues/157361#issuecomment-5651720606
https://github.com/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Sep 16, 2026https://github.com/python/cpython/issues/157361#issuecomment-5692291524
#157362https://github.com/python/cpython/pull/157362
@Fidget-Spinnerhttps://github.com/Fidget-Spinner
kumaraditya303https://github.com/kumaraditya303
on Sep 16, 2026https://github.com/python/cpython/issues/157361#event-31248430732
gh-157361: Implement `anext()` in Python instead of C (#157362)https://github.com/python/cpython/commit/0a6c1ed34118b091230ee38fc047bcc2df8e5c5e
gh-157361https://github.com/python/cpython/issues/157361
#157362https://github.com/python/cpython/pull/157362
0a6c1edhttps://github.com/python/cpython/commit/0a6c1ed34118b091230ee38fc047bcc2df8e5c5e
pythongh-157361: Implement aiter() in Python instead of Chttps://github.com/kumaraditya303/cpython/commit/87872bcf979040979f646e6fc4e4106821a20dec
pythongh-157361https://github.com/python/cpython/issues/157361
87872bchttps://github.com/kumaraditya303/cpython/commit/87872bcf979040979f646e6fc4e4106821a20dec
kumaraditya303https://github.com/kumaraditya303
asyncio.print_call_graph() loses the call stack at anext(agen, default) #157032https://github.com/python/cpython/issues/157032
on Sep 19, 2026https://github.com/python/cpython/issues/157361#event-31440760242
kumaraditya303https://github.com/kumaraditya303
asyncio.print_call_graph() loses the call stack at aiter(callable, stop_value) #157044https://github.com/python/cpython/issues/157044
on Sep 19, 2026https://github.com/python/cpython/issues/157361#event-31440769115
kumaraditya303https://github.com/kumaraditya303
on Oct 20, 2026https://github.com/python/cpython/issues/157361#event-33730718798
gh-157361: Implement `aiter()` in Python instead of C (#157687)https://github.com/python/cpython/commit/cb12c5e514e378ef4e75a3402d2eff1162a321c5
gh-157361https://github.com/python/cpython/issues/157361
#157687https://github.com/python/cpython/pull/157687
cb12c5ehttps://github.com/python/cpython/commit/cb12c5e514e378ef4e75a3402d2eff1162a321c5
gh-157361: Add What's New entry for anext() and aiter() in Python (#1…https://github.com/python/cpython/commit/8b7d6c53eee2226b08bed761d5a1742b5adb8507
gh-157361https://github.com/python/cpython/issues/157361
#1…https://github.com/python/cpython/pull/159867
8b7d6c5https://github.com/python/cpython/commit/8b7d6c53eee2226b08bed761d5a1742b5adb8507
kumaraditya303https://github.com/kumaraditya303
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 20, 2026https://github.com/python/cpython/issues/157361#event-33731499991
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Oct 20, 2026https://github.com/python/cpython/issues/157361
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/157361
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/157361
kumaraditya303https://github.com/kumaraditya303
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
asynciohttps://github.com/orgs/python/projects/29
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.