diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-02-17-11-16.gh-issue-143361.YDnvdC.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-02-17-11-16.gh-issue-143361.YDnvdC.rst new file mode 100644 index 00000000000000..df4e3b61c672cb --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-02-17-11-16.gh-issue-143361.YDnvdC.rst @@ -0,0 +1,2 @@ +Add ``PY_VECTORCALL_ARGUMENTS_OFFSET`` to ``_Py_CallBuiltinClass_StackRefSteal`` to +avoid redundant allocations diff --git a/Python/ceval.c b/Python/ceval.c index 924afaa97443cb..d90ac5c69b9e81 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1273,7 +1273,7 @@ _Py_CallBuiltinClass_StackRefSteal( goto cleanup; } PyTypeObject *tp = (PyTypeObject *)PyStackRef_AsPyObjectBorrow(callable); - res = tp->tp_vectorcall((PyObject *)tp, args_o, total_args, NULL); + res = tp->tp_vectorcall((PyObject *)tp, args_o, total_args | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); STACKREFS_TO_PYOBJECTS_CLEANUP(args_o); assert((res != NULL) ^ (PyErr_Occurred() != NULL)); cleanup: