René's URL Explorer Experiment


Title: gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` by NekoAsakura · Pull Request #149491 · python/cpython · GitHub

Open Graph Title: gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` by NekoAsakura · Pull Request #149491 · python/cpython

X Title: gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` by NekoAsakura · Pull Request #149491 · python/cpython

Description: Thanks for the careful bisect and the empirical fix from @savannahostrowski. ❤️ Benchmark Benchmark unpatched patched Δ for_iter_dict_items 185.8 ms ± 1.6 ms 187.0 ms ± 2.8 ms +0.68% for_iter_dict_keys 154.1 ms ± 2.1 ms 153.9 ms ± 2.6 ms -0.11% for_iter_dict_values 148.2 ms ± 1.0 ms 146.9 ms ± 2.8 ms -0.85% for_iter_set 179.1 ms ± 1.9 ms 179.0 ms ± 2.2 ms -0.07% for_iter_reversed 136.6 ms ± 1.2 ms 136.0 ms ± 1.9 ms -0.47% for_iter_enumerate 201.1 ms ± 2.9 ms 201.1 ms ± 2.4 ms -0.04% for_iter_zip 230.6 ms ± 1.2 ms 227.9 ms ± 1.3 ms -1.15% for_iter_list 114.2 ms ± 1.8 ms 115.6 ms ± 2.2 ms +1.26% for_iter_tuple 104.4 ms ± 1.5 ms 104.7 ms ± 1.7 ms +0.35% for_iter_range 137.6 ms ± 2.5 ms 137.8 ms ± 1.9 ms +0.13% Geometric mean -0.03% Root cause analyse (from opus 4.7) When __next__ is Python-defined, tp_iternext is the generic slot_tp_iternext slot wrapper that re-enters the eval loop via vectorcall_method. Calling it through the new _ITER_NEXT_INLINE (which captures tp_iternext as a baked-in operand and lives in a tight _JUMP_TO_TOP loop) is correct functionally, but each new outer-iteration class causes _GUARD_TYPE_ITER to fail and warm a side-exit. After ~SIDE_EXIT_INITIAL_VALUE (4000) hits at each side-exit, a side trace forms there; _EXIT_TRACE jumps trace-to-trace via TIER2_TO_TIER2, which doesn't re-check the eval-breaker. With MAX_CHAIN_DEPTH=4 traces possible, the chain accumulates ~4×4000+4002 ≈ 20k inner hits before the system spirals into a tier-2-only loop with no signal checkpoints — matching the observed exact threshold. The pre-PR _FOR_ITER_TIER_TWO path goes through _PyForIter_VirtualIteratorNext, which uses an indirect dispatch on Py_TYPE(iter_o)->tp_iternext and does not produce a per-type guard, so no side-trace storm forms. Falling back to that path for slot iterators sidesteps the issue while keeping _ITER_NEXT_INLINE for C-level iterators (dict, set, enumerate, zip, reversed, etc.), which the existing test_for_iter_direct_* tests exercise. Issue: gh-149481

Open Graph Description: Thanks for the careful bisect and the empirical fix from @savannahostrowski. ❤️ Benchmark Benchmark unpatched patched Δ for_iter_dict_items 185.8 ms ± 1.6 ms 187.0 ms ± 2.8 ms +0.68% for_...

X Description: Thanks for the careful bisect and the empirical fix from @savannahostrowski. ❤️ Benchmark Benchmark unpatched patched Δ for_iter_dict_items 185.8 ms ± 1.6 ms 187.0 ms ± 2.8 ms +0.68% for_...

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

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:0bca2b13-cc86-bd0a-0692-5a2a0f4c4b34
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8924:21AC3F:405D786:517358B:6B01FB85
html-safe-nonce5b02c77c10aa44c08a3a73171a20999d02b187e8dbb8af633ca01883603ddd6a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTI0OjIxQUMzRjo0MDVENzg2OjUxNzM1OEI6NkIwMUZCODUiLCJ2aXNpdG9yX2lkIjoiNzY0MjU5NTA1NzQ3NTkxMDUzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd6da98f4ddd92e29de35dd520d37a4d21d0f6ce31b32864bb0ac2f79371e8195
hovercard-subject-tagpull_request:3642718627
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/149491/files
twitter:imagehttps://avatars.githubusercontent.com/u/72689291?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/72689291?s=400&v=4
og:image:altThanks for the careful bisect and the empirical fix from @savannahostrowski. ❤️ Benchmark Benchmark unpatched patched Δ for_iter_dict_items 185.8 ms ± 1.6 ms 187.0 ms ± 2.8 ms +0.68% for_...
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/149491/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F149491%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%2F149491%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/149491/files
Reloadhttps://github.com/python/cpython/pull/149491/files
Reloadhttps://github.com/python/cpython/pull/149491/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
savannahostrowskihttps://github.com/savannahostrowski
python:mainhttps://github.com/python/cpython/tree/main
NekoAsakura:gh-149481/skip-slot-iternexthttps://github.com/NekoAsakura/cpython/tree/gh-149481/skip-slot-iternext
Conversation 6 https://github.com/python/cpython/pull/149491
Commits 5 https://github.com/python/cpython/pull/149491/commits
Checks 72 https://github.com/python/cpython/pull/149491/checks
Files changed https://github.com/python/cpython/pull/149491/files
Please reload this pagehttps://github.com/python/cpython/pull/149491/files
gh-149481: skip FOR_ITER inline specialization for Python __next__ https://github.com/python/cpython/pull/149491/files#top
Show all changes 5 commits https://github.com/python/cpython/pull/149491/files
9c4bbc8 gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` NekoAsakura May 7, 2026 https://github.com/python/cpython/pull/149491/commits/9c4bbc8ad9050a1e5a13ed09cbc8358d65e1d6c5
71a8e7b Merge branch 'main' into gh-149481/skip-slot-iternext savannahostrowski May 7, 2026 https://github.com/python/cpython/pull/149491/commits/71a8e7bcf6a138be7065c990587556b94c1e6bff
340f5da Merge branch 'main' into gh-149481/skip-slot-iternext NekoAsakura May 7, 2026 https://github.com/python/cpython/pull/149491/commits/340f5daf6243683dec572a42209ee41b8438f32a
682db92 Merge branch 'main' into gh-149481/skip-slot-iternext StanFromIreland May 7, 2026 https://github.com/python/cpython/pull/149491/commits/682db92a874dfcfa3e01cc728853fe3e71cfbba6
80dd159 Merge branch 'main' into gh-149481/skip-slot-iternext savannahostrowski May 7, 2026 https://github.com/python/cpython/pull/149491/commits/80dd159df12370946b25410b9de26d0662b0849b
Clear filters https://github.com/python/cpython/pull/149491/files
Please reload this pagehttps://github.com/python/cpython/pull/149491/files
Please reload this pagehttps://github.com/python/cpython/pull/149491/files
pycore_typeobject.h https://github.com/python/cpython/pull/149491/files#diff-9df981eafa9c743230f2e1513191ba147f0fba63d0c51fb7968c1e7093d9e877
test_opt.py https://github.com/python/cpython/pull/149491/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
typeobject.c https://github.com/python/cpython/pull/149491/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
optimizer_bytecodes.c https://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
optimizer_cases.c.h https://github.com/python/cpython/pull/149491/files#diff-ed4567b3e67709ec57bf4df91ef058cfcbe00d7da11cd2a75e38241fa1ca99d2
Include/internal/pycore_typeobject.hhttps://github.com/python/cpython/pull/149491/files#diff-9df981eafa9c743230f2e1513191ba147f0fba63d0c51fb7968c1e7093d9e877
View file https://github.com/NekoAsakura/cpython/blob/80dd159df12370946b25410b9de26d0662b0849b/Include/internal/pycore_typeobject.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/149491/{{ revealButtonHref }}
https://github.com/python/cpython/pull/149491/files#diff-9df981eafa9c743230f2e1513191ba147f0fba63d0c51fb7968c1e7093d9e877
https://github.com/python/cpython/pull/149491/files#diff-9df981eafa9c743230f2e1513191ba147f0fba63d0c51fb7968c1e7093d9e877
Lib/test/test_capi/test_opt.pyhttps://github.com/python/cpython/pull/149491/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
View file https://github.com/NekoAsakura/cpython/blob/80dd159df12370946b25410b9de26d0662b0849b/Lib/test/test_capi/test_opt.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/149491/{{ revealButtonHref }}
https://github.com/python/cpython/pull/149491/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
https://github.com/python/cpython/pull/149491/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L217
Objects/typeobject.chttps://github.com/python/cpython/pull/149491/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
View file https://github.com/NekoAsakura/cpython/blob/80dd159df12370946b25410b9de26d0662b0849b/Objects/typeobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/149491/{{ revealButtonHref }}
https://github.com/python/cpython/pull/149491/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/149491/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L304
Python/optimizer_bytecodes.chttps://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
View file https://github.com/NekoAsakura/cpython/blob/80dd159df12370946b25410b9de26d0662b0849b/Python/optimizer_bytecodes.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/149491/{{ revealButtonHref }}
https://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
https://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
https://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
https://github.com/python/cpython/pull/149491/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
Python/optimizer_cases.c.hhttps://github.com/python/cpython/pull/149491/files#diff-ed4567b3e67709ec57bf4df91ef058cfcbe00d7da11cd2a75e38241fa1ca99d2
View file https://github.com/NekoAsakura/cpython/blob/80dd159df12370946b25410b9de26d0662b0849b/Python/optimizer_cases.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/149491/files
Please reload this pagehttps://github.com/python/cpython/pull/149491/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.