]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (#145826)
authorSam Gross <colesbury@gmail.com>
Tue, 17 Mar 2026 18:24:44 +0000 (14:24 -0400)
committerGitHub <noreply@github.com>
Tue, 17 Mar 2026 18:24:44 +0000 (14:24 -0400)
commite0f7c1097e19b6f5c2399e19f283c9fb373c243f
tree535c10ea22a621cd71efefe496725557de45a431
parent966fc8153141ef41885dc36ab3522487657c06fe
gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (#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.
Include/internal/pycore_call.h
Include/internal/pycore_function.h
Include/internal/pycore_object.h
Misc/NEWS.d/next/Core_and_Builtins/2026-03-10-22-38-40.gh-issue-145779.5375381d80.rst [new file with mode: 0644]
Objects/call.c
Objects/classobject.c
Objects/funcobject.c
Objects/object.c
Python/ceval.c
Tools/ftscalingbench/ftscalingbench.py