]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-145779: Improve classmethod/staticmethod scaling in free-threaded build...
authorSam Gross <colesbury@gmail.com>
Thu, 19 Mar 2026 14:49:12 +0000 (10:49 -0400)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2026 14:49:12 +0000 (10:49 -0400)
commitfa3143a1d2d6d241632c835cbe8fc541adf60f68
treecdc0c4a7611f48f148c16ce8e51e1779d30a4d02
parent7f29c1d0dabb84fc91caf874881b501345702793
[3.14] gh-145779: Improve classmethod/staticmethod scaling in free-threaded build (gh-145826) (#146088)

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 e0f7c1097e19b6f5c2399e19f283c9fb373c243f)
15 files changed:
Include/internal/pycore_call.h
Include/internal/pycore_ceval.h
Include/internal/pycore_function.h
Include/internal/pycore_object.h
Include/internal/pycore_stackref.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/bytecodes.c
Python/ceval.c
Python/executor_cases.c.h
Python/generated_cases.c.h
Tools/ftscalingbench/ftscalingbench.py