René's URL Explorer Experiment


Title: gh-92810: Lock-free cache implementation for ABCMeta by kumaraditya303 · Pull Request #162361 · python/cpython · GitHub

Open Graph Title: gh-92810: Lock-free cache implementation for ABCMeta by kumaraditya303 · Pull Request #162361 · python/cpython

X Title: gh-92810: Lock-free cache implementation for ABCMeta by kumaraditya303 · Pull Request #162361 · python/cpython

Description: Replace the sets of weak references used for the ABC registry and the positive/negative isinstance caches with hash tables keyed by class identity. Cached isinstance() and issubclass() checks are served without locking or reference count updates on the free-threaded build, and a negative result is no longer propagated into the cache of every subclass of the ABC, which made such checks quadratic for large hierarchies. Benchmark results on Apple M4 (10 cores), release build: Single-threaded (default build) ns per call: Case main PR Speedup isinstance() hit, subclass 75.2 49.8 1.5x isinstance() hit, registered class 172.0 50.4 3.4x isinstance() miss, cached 81.6 50.4 1.6x issubclass() hit 68.9 49.5 1.4x issubclass() miss, cached 76.2 50.3 1.5x isinstance([], Sequence) 78.4 54.2 1.4x isinstance(1, Sequence) 86.5 52.5 1.6x isinstance({}, Mapping) 96.5 68.6 1.4x uncached hit 150 69 2.2x uncached miss, 2 subclasses 391 177 2.2x uncached miss, 100 subclasses 7,063 3,676 1.9x uncached miss, 1000 subclasses 77,570 36,069 2.2x re-check after register(), 100 subclasses 27,257 4,924 5.5x new subclass + first isinstance() 2,841 2,543 1.1x Multi-threaded (free-threaded build) Each thread checks its own objects, ns per call per thread: Case main 1T main 8T PR 1T PR 8T Speedup at 8T isinstance() hit 92.0 1,374 62.3 105 13x isinstance() miss, cached 117 1,351 70.3 109 12x isinstance() hit, registered class 289 3,586 77.5 129 28x issubclass() hit 105 1,476 62.5 108 14x isinstance([], Sequence) 121 1,268 70.3 116 11x isinstance(1, Sequence) 128 1,427 72.4 117 12x uncached check (new class each time) 3,939 46,160 2,845 33,369 1.4x non-ABC isinstance() 14.1 26.3 15.8 28.8 – Cached checks now scale the same as a non-ABC isinstance(). Uncached checks are faster but still don't scale, same as main. Reproducers from the issue Time and peak RSS, default build: Reproducer main PR original report, 5,000 iterations 1.56 s, 30.8 MiB 0.055 s, 14.8 MiB original report, 20,000 iterations 3.51 s, 31.0 MiB 0.22 s, 15.2 MiB Viicos's, 10,000 iterations 8.85 s, 46.0 MiB 0.11 s, 14.5 MiB dolfinus's, 6,000 objects 11.5 s, 3,796 MiB 0.78 s, 33.0 MiB Free-threaded build: Reproducer main PR original report, 5,000 iterations 0.23 s, 15.0 MiB 0.060 s, 15.6 MiB original report, 20,000 iterations 0.92 s, 15.0 MiB 0.23 s, 15.6 MiB Viicos's, 10,000 iterations 0.77 s, 15.6 MiB 0.10 s, 15.3 MiB dolfinus's, 6,000 objects 11.6 s, 3,880 MiB 0.84 s, 36.3 MiB The memory usage of @dolfinus's reproducer goes from ~3.8 GiB to ~35 MiB and it is ~14x faster. Issue: gh-92810

Open Graph Description: Replace the sets of weak references used for the ABC registry and the positive/negative isinstance caches with hash tables keyed by class identity. Cached isinstance() and issubclass() checks are s...

X Description: Replace the sets of weak references used for the ABC registry and the positive/negative isinstance caches with hash tables keyed by class identity. Cached isinstance() and issubclass() checks are s...

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

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:4245eda1-2dd2-60fc-b276-1fc56d6911fc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD208:27E5CD:389D3F5:4865D7E:6B01EC76
html-safe-nonce6cedc3e1bd24c049b9b804a1949f58ceea21eb38b03ce8f0de3b64b6356f504f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjA4OjI3RTVDRDozODlEM0Y1OjQ4NjVEN0U6NkIwMUVDNzYiLCJ2aXNpdG9yX2lkIjoiNjg3Mzk4ODM0NzUwMTYwMzk1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2e0264a265b1390eb3bc7a6c9f5d2c0fd20f9a14d09173a1f12e955b1ed3cda4
hovercard-subject-tagpull_request:5425540742
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/162361/files
twitter:imagehttps://avatars.githubusercontent.com/u/59607654?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/59607654?s=400&v=4
og:image:altReplace the sets of weak references used for the ABC registry and the positive/negative isinstance caches with hash tables keyed by class identity. Cached isinstance() and issubclass() checks are s...
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/162361/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F162361%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%2F162361%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/162361/files
Reloadhttps://github.com/python/cpython/pull/162361/files
Reloadhttps://github.com/python/cpython/pull/162361/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
kumaraditya303https://github.com/kumaraditya303
python:mainhttps://github.com/python/cpython/tree/main
kumaraditya303:gh-92810-abc-c-tableshttps://github.com/kumaraditya303/cpython/tree/gh-92810-abc-c-tables
Conversation 0 https://github.com/python/cpython/pull/162361
Commits 5 https://github.com/python/cpython/pull/162361/commits
Checks 55 https://github.com/python/cpython/pull/162361/checks
Files changed 10 https://github.com/python/cpython/pull/162361/files
gh-92810: Lock-free cache implementation for ABCMeta https://github.com/python/cpython/pull/162361/files#top
Show all changes 5 commits https://github.com/python/cpython/pull/162361/files
edf2543 gh-92810: Lock-free cache implementation for ABCMeta kumaraditya303 Sep 15, 2026 https://github.com/python/cpython/pull/162361/commits/edf2543372e96439274be5f4ad163abb84a3ede0
859a57e Make the shared empty table const kumaraditya303 Nov 21, 2026 https://github.com/python/cpython/pull/162361/commits/859a57e21c856e782b032945209fe86dc1e5adcd
a7273de close file after use kumaraditya303 Nov 21, 2026 https://github.com/python/cpython/pull/162361/commits/a7273de1ab7374c04f55bc3f5bc2bb103eca2f9a
8b5148b use os.devnull kumaraditya303 Nov 21, 2026 https://github.com/python/cpython/pull/162361/commits/8b5148b2a219c6e2cf6c50f260c17f32651c71f8
dc50cfe fix import kumaraditya303 Nov 21, 2026 https://github.com/python/cpython/pull/162361/commits/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f
Clear filters https://github.com/python/cpython/pull/162361/files
Please reload this pagehttps://github.com/python/cpython/pull/162361/files
Please reload this pagehttps://github.com/python/cpython/pull/162361/files
pycore_global_objects_fini_generated.h https://github.com/python/cpython/pull/162361/files#diff-31f682b2a04cda997f449a9816ee5fae305e3bfa7357afcb794615921c6a88d2
pycore_global_strings.h https://github.com/python/cpython/pull/162361/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
pycore_runtime_init_generated.h https://github.com/python/cpython/pull/162361/files#diff-69a1fc720f0b1e9005cf7717dd81c823399da81dd2f6480664b51238c1ef93f0
pycore_unicodeobject_generated.h https://github.com/python/cpython/pull/162361/files#diff-510f6084b63d39305481b719ae0a29475ba759e259a8e4cee4f07c451ffbb2d6
abc.py https://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
test_abc.py https://github.com/python/cpython/pull/162361/files#diff-e020d5ddd536ec48b0414753af7d5240750a05262f32dad378b4c79e6cc3743d
test_abc.py https://github.com/python/cpython/pull/162361/files#diff-d4eedf42a76e3068eea685bbccd560ef0de5a5553c8c8040cfb01c0d4d4272de
2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rst https://github.com/python/cpython/pull/162361/files#diff-b833de3a0b1a704230a98c660704f3645506b3f12d53b05ca7de7c0af2875153
_abc.c https://github.com/python/cpython/pull/162361/files#diff-d88c94f372c2e10cea3d5f2e39c6ce940eb2cfe664d913eeab7f74d23d636687
_abc.c.h https://github.com/python/cpython/pull/162361/files#diff-510d3b07367797945f760f8ac5071f53ceae465597c43513d195eab9ac80baa9
Include/internal/pycore_global_objects_fini_generated.hhttps://github.com/python/cpython/pull/162361/files#diff-31f682b2a04cda997f449a9816ee5fae305e3bfa7357afcb794615921c6a88d2
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Include/internal/pycore_global_objects_fini_generated.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/162361/files
Include/internal/pycore_global_strings.hhttps://github.com/python/cpython/pull/162361/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Include/internal/pycore_global_strings.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162361/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162361/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
https://github.com/python/cpython/pull/162361/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
Include/internal/pycore_runtime_init_generated.hhttps://github.com/python/cpython/pull/162361/files#diff-69a1fc720f0b1e9005cf7717dd81c823399da81dd2f6480664b51238c1ef93f0
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Include/internal/pycore_runtime_init_generated.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/162361/files
Include/internal/pycore_unicodeobject_generated.hhttps://github.com/python/cpython/pull/162361/files#diff-510f6084b63d39305481b719ae0a29475ba759e259a8e4cee4f07c451ffbb2d6
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Include/internal/pycore_unicodeobject_generated.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/162361/files
Lib/abc.pyhttps://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Lib/abc.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162361/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
https://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
https://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
https://github.com/python/cpython/pull/162361/files#diff-14b22bd70f1a636134e1266305965ed8cf483e43c802b6165e8ed4c3b8ee1f9f
Lib/test/test_abc.pyhttps://github.com/python/cpython/pull/162361/files#diff-e020d5ddd536ec48b0414753af7d5240750a05262f32dad378b4c79e6cc3743d
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Lib/test/test_abc.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162361/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162361/files#diff-e020d5ddd536ec48b0414753af7d5240750a05262f32dad378b4c79e6cc3743d
https://github.com/python/cpython/pull/162361/files#diff-e020d5ddd536ec48b0414753af7d5240750a05262f32dad378b4c79e6cc3743d
Lib/test/test_free_threading/test_abc.pyhttps://github.com/python/cpython/pull/162361/files#diff-d4eedf42a76e3068eea685bbccd560ef0de5a5553c8c8040cfb01c0d4d4272de
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Lib/test/test_free_threading/test_abc.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162361/{{ revealButtonHref }}
Misc/NEWS.d/next/Library/2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rsthttps://github.com/python/cpython/pull/162361/files#diff-b833de3a0b1a704230a98c660704f3645506b3f12d53b05ca7de7c0af2875153
View file https://github.com/python/cpython/blob/dc50cfe7dc369e8f8cd95bedfc217d32b1e14e6f/Misc/NEWS.d/next/Library/2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162361/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/162361/files
Please reload this pagehttps://github.com/python/cpython/pull/162361/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.