From f2afdf33523162d5911de3263b4a9785d7c49a20 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 14 Aug 2022 20:43:42 +0530 Subject: [PATCH] GH-95977: Speed up calling pure python descriptor __get__ with vectorcall (gh-95978) --- .../2022-08-14-10-04-44.gh-issue-95977.gCTZb9.rst | 1 + Objects/typeobject.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-08-14-10-04-44.gh-issue-95977.gCTZb9.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-08-14-10-04-44.gh-issue-95977.gCTZb9.rst b/Misc/NEWS.d/next/Core and Builtins/2022-08-14-10-04-44.gh-issue-95977.gCTZb9.rst new file mode 100644 index 00000000000..b265c770233 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-08-14-10-04-44.gh-issue-95977.gCTZb9.rst @@ -0,0 +1 @@ +Optimized calling :meth:`~object.__get__` with vectorcall. Patch by Kumar Aditya. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index da02e86f94e..27b12a00d77 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -8242,7 +8242,8 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) obj = Py_None; if (type == NULL) type = Py_None; - return PyObject_CallFunctionObjArgs(get, self, obj, type, NULL); + PyObject *stack[3] = {self, obj, type}; + return PyObject_Vectorcall(get, stack, 3, NULL); } static int