René's URL Explorer Experiment


Title: gh-162258: Use vectorcall for slot wrappers by cmaloney · Pull Request #162369 · python/cpython · GitHub

Open Graph Title: gh-162258: Use vectorcall for slot wrappers by cmaloney · Pull Request #162369 · python/cpython

X Title: gh-162258: Use vectorcall for slot wrappers by cmaloney · Pull Request #162369 · python/cpython

Description: Add a vectorcall member to PyWrapperDescrObject so slots which don't require a args tuple or kwargs dict can avoid constructing them. Wrappers which take a keywords dict (__init__ and __call__) keep calling through tp_call, as METH_VARARGS functions do: with vectorcall, PyObject_Call() with **kwargs would unpack the dict into an array only for the wrapper to build a new dict. Removing the PyWrapperFlag_KEYWORDS check in PyDescr_NewWrapper() shows it: dict.__init__({}, **kw) goes from 70.6 ns to 99.0 ns. The object grows by one pointer (sys.getsizeof(object.__init__): 72 -> 80 bytes) but stays in the same allocator size class: on the default build, sys.getallocatedblocks() and max RSS are unchanged at startup (about 1,000 slot wrappers) and after importing asyncio, json, dataclasses, collections, decimal, typing, re, email and http.client. Results and error messages are unchanged. Benchmark main PR c['x'] = 1 35.5 ns 26.6 ns: 1.33x faster int.__add__(1, 2) 26.9 ns 21.5 ns: 1.25x faster object.__setattr__(o, 'x', 1) 37.2 ns 30.8 ns: 1.21x faster frozen_triple(1, 2, 3) 156 ns 132 ns: 1.18x faster dict.__init__({}, **kw) 68.9 ns 70.9 ns: 1.03x slower The dict.__init__ is ~2ns which is within noise for my machine. dict_subclass(), list_subclass() and pair(1, 2) were not significantly different. dict_subclass(), list_subclass() and dict.__init__({}, **kw) call __init__, which takes the same path as before. Across builds of the same code they moved by up to 7 ns either way. Under callgrind, dict.__init__({}, **kw) costs about 20 more instructions per call in the call path (the self reference and type check); perf stat pinned to one core shows no cycle difference for the subclass rows beyond run-to-run variance. Linux x86-64, clang PGO+LTO builds, pyperf: import pyperf runner = pyperf.Runner() setup = """ from collections import Counter from dataclasses import dataclass @dataclass(frozen=True) class frozen_triple: a: int b: int c: int @dataclass class pair: a: int b: int class C: pass class list_subclass(list): def __init__(self): super().__init__() class dict_subclass(dict): def __init__(self): super().__init__(a=1) o = C() c = Counter() kw = {'x': 1} """ for stmt in [ "c['x'] = 1", "object.__setattr__(o, 'x', 1)", "int.__add__(1, 2)", "frozen_triple(1, 2, 3)", "dict_subclass()", "list_subclass()", "dict.__init__({}, **kw)", "pair(1, 2)", ]: runner.timeit(stmt, stmt, setup) Issue: gh-162258

Open Graph Description: Add a vectorcall member to PyWrapperDescrObject so slots which don't require a args tuple or kwargs dict can avoid constructing them. Wrappers which take a keywords dict (__init__ and __call__)...

X Description: Add a vectorcall member to PyWrapperDescrObject so slots which don't require a args tuple or kwargs dict can avoid constructing them. Wrappers which take a keywords dict (__init__ and __cal...

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

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:ca457a8f-7a4f-bb87-8001-6b22a7c26660
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAC5E:2D40DE:2B7C488:37677E5:6B01EC64
html-safe-nonceced609e156a622795350161f71e69f040b6fd230cf320b80481cf18d83c1a8b1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzVFOjJENDBERToyQjdDNDg4OjM3Njc3RTU6NkIwMUVDNjQiLCJ2aXNpdG9yX2lkIjoiNzIzNTI1NTQxNTYxNTkwODk2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacee476bf22fc15b397391375f88dd33745150ff387e0ea97610e6831aaa0d7ebd
hovercard-subject-tagpull_request:5426098156
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/162369/files
twitter:imagehttps://avatars.githubusercontent.com/u/751088?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/751088?s=400&v=4
og:image:altAdd a vectorcall member to PyWrapperDescrObject so slots which don't require a args tuple or kwargs dict can avoid constructing them. Wrappers which take a keywords dict (__init__ and __call__)...
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/162369/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F162369%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%2F162369%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/162369/files
Reloadhttps://github.com/python/cpython/pull/162369/files
Reloadhttps://github.com/python/cpython/pull/162369/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
cmaloneyhttps://github.com/cmaloney
python:mainhttps://github.com/python/cpython/tree/main
cmaloney:landable/wrapper-one-tuplehttps://github.com/cmaloney/cpython/tree/landable/wrapper-one-tuple
Conversation 0 https://github.com/python/cpython/pull/162369
Commits 1 https://github.com/python/cpython/pull/162369/commits
Checks 58 https://github.com/python/cpython/pull/162369/checks
Files changed 4 https://github.com/python/cpython/pull/162369/files
gh-162258: Use vectorcall for slot wrappers https://github.com/python/cpython/pull/162369/files#top
Show all changes 1 commit https://github.com/python/cpython/pull/162369/files
0df9822 gh-162258: Use vectorcall for slot wrappers cmaloney Nov 21, 2026 https://github.com/python/cpython/pull/162369/commits/0df98222bf428dd076ba2f06608402fa07e27c35
Clear filters https://github.com/python/cpython/pull/162369/files
Please reload this pagehttps://github.com/python/cpython/pull/162369/files
Please reload this pagehttps://github.com/python/cpython/pull/162369/files
descrobject.h https://github.com/python/cpython/pull/162369/files#diff-3e9ced09c533bf85e137637d4ee4439e365f5c975732b54eaca23419ba24b22a
test_descr.py https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
test_sys.py https://github.com/python/cpython/pull/162369/files#diff-f3ae0e3fbb12fe0717e2d9d8801f5d9f3091c34254d1302b228422d7d07fdc5d
descrobject.c https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
Include/cpython/descrobject.hhttps://github.com/python/cpython/pull/162369/files#diff-3e9ced09c533bf85e137637d4ee4439e365f5c975732b54eaca23419ba24b22a
View file https://github.com/python/cpython/blob/0df98222bf428dd076ba2f06608402fa07e27c35/Include/cpython/descrobject.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162369/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162369/files#diff-3e9ced09c533bf85e137637d4ee4439e365f5c975732b54eaca23419ba24b22a
https://github.com/python/cpython/pull/162369/files#diff-3e9ced09c533bf85e137637d4ee4439e365f5c975732b54eaca23419ba24b22a
Lib/test/test_descr.pyhttps://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
View file https://github.com/python/cpython/blob/0df98222bf428dd076ba2f06608402fa07e27c35/Lib/test/test_descr.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162369/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
https://github.com/python/cpython/pull/162369/files#diff-6b813570d02ae3544e7e0233ae21d647f8e2dc47486495557e8d16c80460e85b
Lib/test/test_sys.pyhttps://github.com/python/cpython/pull/162369/files#diff-f3ae0e3fbb12fe0717e2d9d8801f5d9f3091c34254d1302b228422d7d07fdc5d
View file https://github.com/python/cpython/blob/0df98222bf428dd076ba2f06608402fa07e27c35/Lib/test/test_sys.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162369/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162369/files#diff-f3ae0e3fbb12fe0717e2d9d8801f5d9f3091c34254d1302b228422d7d07fdc5d
https://github.com/python/cpython/pull/162369/files#diff-f3ae0e3fbb12fe0717e2d9d8801f5d9f3091c34254d1302b228422d7d07fdc5d
Objects/descrobject.chttps://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
View file https://github.com/python/cpython/blob/0df98222bf428dd076ba2f06608402fa07e27c35/Objects/descrobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/162369/{{ revealButtonHref }}
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
https://github.com/python/cpython/pull/162369/files#diff-7952643fe36a8662b3e4be2c6478b06b1af5b5754fc25eaf3eb4b46569659264
Please reload this pagehttps://github.com/python/cpython/pull/162369/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.