René's URL Explorer Experiment


Title: gh-138912: Add fast path for match class patterns without sub-patterns by cdce8p · Pull Request #144820 · python/cpython · GitHub

Open Graph Title: gh-138912: Add fast path for match class patterns without sub-patterns by cdce8p · Pull Request #144820 · python/cpython

X Title: gh-138912: Add fast path for match class patterns without sub-patterns by cdce8p · Pull Request #144820 · python/cpython

Description: Extracted from #139080. This builds on the work merged with 75d4839. Add a fast path for match class patterns without any sub-patterns. This avoids creating a new (empty) tuple, pushing it to the stack and subsequently unpacking the tuple result from the MATCH_CLASS opcode again. __ Micro benchmarks with all specializations enabled. Micro benchmark (bare class pattern) from timeit import timeit setup = """ class A: def __init__(self, x, y): self.x = x self.y = y a = A(1, 2) def f1(a): if isinstance(a, A): return True return False def f2(a): match a: case A(): return True return False """ print(f"If\t{timeit("f1(a)", setup, number=10**7)}") print(f"Match\t{timeit("f2(a)", setup, number=10**7)}") # Before If 0.2718 Match 0.2659 # After Match 0.2253 -15.27% If specialization disabled, the performance improvement is even better with -37.44%. Issue: gh-138912 📚 Documentation preview 📚: https://cpython-previews--144820.org.readthedocs.build/

Open Graph Description: Extracted from #139080. This builds on the work merged with 75d4839. Add a fast path for match class patterns without any sub-patterns. This avoids creating a new (empty) tuple, pushing it to the s...

X Description: Extracted from #139080. This builds on the work merged with 75d4839. Add a fast path for match class patterns without any sub-patterns. This avoids creating a new (empty) tuple, pushing it to the s...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d60ebf3a-e524-93ea-457c-0522737f65ee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE3C6:2FE627:1611F:1C089:6A526A1F
html-safe-nonce8592212a5d3a3291419749f83465c07734cdd16ae2eea34a5ab326d55998d611
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0M2OjJGRTYyNzoxNjExRjoxQzA4OTo2QTUyNkExRiIsInZpc2l0b3JfaWQiOiI0NjE1NTgyODAxMDg5MTYxNzU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac9f07b88ebfe92a4919d876eda1c642155cc138ce772b1a96d5cebdfd22eb0486
hovercard-subject-tagpull_request:3284795985
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/144820/files
twitter:imagehttps://avatars.githubusercontent.com/u/30130371?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/30130371?s=400&v=4
og:image:altExtracted from #139080. This builds on the work merged with 75d4839. Add a fast path for match class patterns without any sub-patterns. This avoids creating a new (empty) tuple, pushing it to the s...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/144820/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F144820%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F144820%2Ffiles
Sign up https://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/144820/files
Reloadhttps://github.com/python/cpython/pull/144820/files
Reloadhttps://github.com/python/cpython/pull/144820/files
Please reload this pagehttps://github.com/python/cpython/pull/144820/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/144820/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
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
cdce8phttps://github.com/cdce8p
python:mainhttps://github.com/python/cpython/tree/main
cdce8p:match-class-opcode-isinstancehttps://github.com/cdce8p/cpython/tree/match-class-opcode-isinstance
Conversation 6 https://github.com/python/cpython/pull/144820
Commits 10 https://github.com/python/cpython/pull/144820/commits
Checks 50 https://github.com/python/cpython/pull/144820/checks
Files changed https://github.com/python/cpython/pull/144820/files
Please reload this pagehttps://github.com/python/cpython/pull/144820/files
gh-138912: Add fast path for match class patterns without sub-patterns https://github.com/python/cpython/pull/144820/files#top
Show all changes 10 commits https://github.com/python/cpython/pull/144820/files
7f8b4b2 gh-138912: Add fast path for match class patterns without sub-patterns cdce8p Feb 14, 2026 https://github.com/python/cpython/pull/144820/commits/7f8b4b22c29b4307fd96fb523e59199dd3c6e39d
7982d8f Merge branch 'main' cdce8p Mar 14, 2026 https://github.com/python/cpython/pull/144820/commits/7982d8fbc75bda811956d14ec83aea3a643bf456
1ed79b7 Fix test case cdce8p Mar 14, 2026 https://github.com/python/cpython/pull/144820/commits/1ed79b78a9b939e7d00e4395c3b31f63f5c0931d
93c96b0 Merge branch 'main' cdce8p Mar 23, 2026 https://github.com/python/cpython/pull/144820/commits/93c96b0e31df671260f2382d83d877e0909718c0
d9efeaa Merge branch 'main' cdce8p Apr 12, 2026 https://github.com/python/cpython/pull/144820/commits/d9efeaa4e3386b5e6e8b281b242ad3e7bb043f79
906dcb3 Merge branch 'main' cdce8p May 8, 2026 https://github.com/python/cpython/pull/144820/commits/906dcb321b33d0bc7253c9aacf7c6af771e45f4e
dd07e55 Merge branch 'main' cdce8p Jun 24, 2026 https://github.com/python/cpython/pull/144820/commits/dd07e55b2e0f4aebbafb3ea875cc1e84f23a24b0
1681dd5 Merge branch 'main' cdce8p Jun 29, 2026 https://github.com/python/cpython/pull/144820/commits/1681dd5163524ae2ac541de1491c117c4634621a
2307ddd Merge branch 'main' cdce8p Jul 6, 2026 https://github.com/python/cpython/pull/144820/commits/2307ddd75f7c72d4f6b1f7f914e1058a9ec28840
53fd8f4 Replace MATCH_CLASS_ISINSTANCE with CALL_INTRINSIC_2 cdce8p Jun 30, 2026 https://github.com/python/cpython/pull/144820/commits/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db
Clear filters https://github.com/python/cpython/pull/144820/files
Please reload this pagehttps://github.com/python/cpython/pull/144820/files
Please reload this pagehttps://github.com/python/cpython/pull/144820/files
dis.rst https://github.com/python/cpython/pull/144820/files#diff-eaa488fc50d23b30ca8b24ab19e9c91c1c941339847af993e908f006eec0653b
pycore_intrinsics.h https://github.com/python/cpython/pull/144820/files#diff-5e41701496b305f45bd48edf501335421d6901638b7522d8a693fc43b17ad55b
test_opt.py https://github.com/python/cpython/pull/144820/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rst https://github.com/python/cpython/pull/144820/files#diff-55b874f3a2e43cf42d3badb4125a3f1e17455e3d286301622b86486e4ee3b34c
codegen.c https://github.com/python/cpython/pull/144820/files#diff-6d58b0ddc066ad12ebc378b62c4189335bd57c83aece11072c76fd86a78a1a4a
intrinsics.c https://github.com/python/cpython/pull/144820/files#diff-1c4afe2e9762d9307a6b09ea1e59abb8ba929f2c1c92d15e911c6a93f5fd4c6b
Doc/library/dis.rsthttps://github.com/python/cpython/pull/144820/files#diff-eaa488fc50d23b30ca8b24ab19e9c91c1c941339847af993e908f006eec0653b
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Doc/library/dis.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/pull/144820/files#diff-eaa488fc50d23b30ca8b24ab19e9c91c1c941339847af993e908f006eec0653b
https://github.com/python/cpython/pull/144820/files#diff-eaa488fc50d23b30ca8b24ab19e9c91c1c941339847af993e908f006eec0653b
Include/internal/pycore_intrinsics.hhttps://github.com/python/cpython/pull/144820/files#diff-5e41701496b305f45bd48edf501335421d6901638b7522d8a693fc43b17ad55b
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Include/internal/pycore_intrinsics.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/pull/144820/files#diff-5e41701496b305f45bd48edf501335421d6901638b7522d8a693fc43b17ad55b
https://github.com/python/cpython/pull/144820/files#diff-5e41701496b305f45bd48edf501335421d6901638b7522d8a693fc43b17ad55b
Lib/test/test_capi/test_opt.pyhttps://github.com/python/cpython/pull/144820/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Lib/test/test_capi/test_opt.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/pull/144820/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
https://github.com/python/cpython/pull/144820/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
https://github.com/python/cpython/pull/144820/files#diff-67b5bd915e37f77df79907865982648172c27d3b96fbb072b30a73c6a2735439
Misc/NEWS.d/next/Core_and_Builtins/2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rsthttps://github.com/python/cpython/pull/144820/files#diff-55b874f3a2e43cf42d3badb4125a3f1e17455e3d286301622b86486e4ee3b34c
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Misc/NEWS.d/next/Core_and_Builtins/2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L231
Python/codegen.chttps://github.com/python/cpython/pull/144820/files#diff-6d58b0ddc066ad12ebc378b62c4189335bd57c83aece11072c76fd86a78a1a4a
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Python/codegen.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/pull/144820/files#diff-6d58b0ddc066ad12ebc378b62c4189335bd57c83aece11072c76fd86a78a1a4a
https://github.com/python/cpython/pull/144820/files#diff-6d58b0ddc066ad12ebc378b62c4189335bd57c83aece11072c76fd86a78a1a4a
Python/intrinsics.chttps://github.com/python/cpython/pull/144820/files#diff-1c4afe2e9762d9307a6b09ea1e59abb8ba929f2c1c92d15e911c6a93f5fd4c6b
View file https://github.com/python/cpython/blob/53fd8f49f2e9ba86fd55a361a8d1c4756d3d36db/Python/intrinsics.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/144820/{{ revealButtonHref }}
https://github.com/python/cpython/pull/144820/files#diff-1c4afe2e9762d9307a6b09ea1e59abb8ba929f2c1c92d15e911c6a93f5fd4c6b
https://github.com/python/cpython/pull/144820/files#diff-1c4afe2e9762d9307a6b09ea1e59abb8ba929f2c1c92d15e911c6a93f5fd4c6b
https://github.com/python/cpython/pull/144820/files#diff-1c4afe2e9762d9307a6b09ea1e59abb8ba929f2c1c92d15e911c6a93f5fd4c6b
Please reload this pagehttps://github.com/python/cpython/pull/144820/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.