summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-30 01:05:01 (GMT)
committerGitHub <noreply@github.com>2023-06-30 01:05:01 (GMT)
commit8c5f74fc89e35827c52753fe620b32207d537319 (patch)
tree62a1eba40b01250e97f2c5cd263456b4cb7e734a /Modules/_functoolsmodule.c
parente7bc8d16364bde54487eab349a29d58345e35f28 (diff)
downloadcpython-8c5f74fc89e35827c52753fe620b32207d537319.zip
cpython-8c5f74fc89e35827c52753fe620b32207d537319.tar.gz
cpython-8c5f74fc89e35827c52753fe620b32207d537319.tar.bz2
gh-106023: Update code using _PyObject_FastCall() (#106257)
Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index aa566c3..c987485 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -594,21 +594,15 @@ keyobject_call(keyobject *ko, PyObject *args, PyObject *kwds)
static PyObject *
keyobject_richcompare(PyObject *ko, PyObject *other, int op)
{
- PyObject *res;
- PyObject *x;
- PyObject *y;
- PyObject *compare;
- PyObject *answer;
- PyObject* stack[2];
-
if (!Py_IS_TYPE(other, Py_TYPE(ko))) {
PyErr_Format(PyExc_TypeError, "other argument must be K instance");
return NULL;
}
- compare = ((keyobject *) ko)->cmp;
+
+ PyObject *compare = ((keyobject *) ko)->cmp;
assert(compare != NULL);
- x = ((keyobject *) ko)->object;
- y = ((keyobject *) other)->object;
+ PyObject *x = ((keyobject *) ko)->object;
+ PyObject *y = ((keyobject *) other)->object;
if (!x || !y){
PyErr_Format(PyExc_AttributeError, "object");
return NULL;
@@ -617,14 +611,13 @@ keyobject_richcompare(PyObject *ko, PyObject *other, int op)
/* Call the user's comparison function and translate the 3-way
* result into true or false (or error).
*/
- stack[0] = x;
- stack[1] = y;
- res = _PyObject_FastCall(compare, stack, 2);
+ PyObject* args[2] = {x, y};
+ PyObject *res = PyObject_Vectorcall(compare, args, 2, NULL);
if (res == NULL) {
return NULL;
}
- answer = PyObject_RichCompare(res, _PyLong_GetZero(), op);
+ PyObject *answer = PyObject_RichCompare(res, _PyLong_GetZero(), op);
Py_DECREF(res);
return answer;
}