Skip to content

[3.14] gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (gh-145826)#146088

Draft
colesbury wants to merge 2 commits intopython:3.14from
colesbury:backport-e0f7c10-3.14
Draft

[3.14] gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (gh-145826)#146088
colesbury wants to merge 2 commits intopython:3.14from
colesbury:backport-e0f7c10-3.14

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Mar 17, 2026

Add special cases for classmethod and staticmethod descriptors in _PyObject_GetMethodStackRef() to avoid calling tp_descr_get, which avoids reference count contention on the bound method and underlying callable. This improves scaling when calling classmethods and staticmethods from multiple threads.

Also refactor method_vectorcall in classobject.c into a new _PyObject_VectorcallPrepend() helper so that it can be used by PyObject_VectorcallMethod as well.

(cherry picked from commit e0f7c10)

@colesbury colesbury changed the title gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (gh-145826) [3.14] gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (gh-145826) Mar 17, 2026
…ree-threaded build (python#145826)

Add special cases for classmethod and staticmethod descriptors in
_PyObject_GetMethodStackRef() to avoid calling tp_descr_get, which
avoids reference count contention on the bound method and underlying
callable. This improves scaling when calling classmethods and
staticmethods from multiple threads.

Also refactor method_vectorcall in classobject.c into a new
_PyObject_VectorcallPrepend() helper so that it can be used by
PyObject_VectorcallMethod as well.

(cherry picked from commit e0f7c10)
@colesbury colesbury force-pushed the backport-e0f7c10-3.14 branch from 23966bc to 0cf3af1 Compare March 17, 2026 21:14
@colesbury colesbury added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 17, 2026
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @colesbury for commit b879eff 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F146088%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants