diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-08-19 15:48:51 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-08-19 15:48:51 (GMT) |
commit | a7720f61aa8f94371e940d498be4c2cf8804f36f (patch) | |
tree | 3e9b30cf3bcad5bfbab21c6686ddd162f9f1156b /Objects/typeobject.c | |
parent | 8a31c820930536ffe3b44d99252ba9f3bb98ce58 (diff) | |
download | cpython-a7720f61aa8f94371e940d498be4c2cf8804f36f.zip cpython-a7720f61aa8f94371e940d498be4c2cf8804f36f.tar.gz cpython-a7720f61aa8f94371e940d498be4c2cf8804f36f.tar.bz2 |
contains and rich compare slots use fast call
Issue #27128. Modify slot_sq_contains() and slot_tp_richcompare() to use fast
call to avoid a temporary tuple to pass a single positional parameter.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index d141bf4..a190e7a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5853,7 +5853,7 @@ slot_sq_ass_item(PyObject *self, Py_ssize_t index, PyObject *value) static int slot_sq_contains(PyObject *self, PyObject *value) { - PyObject *func, *res, *args; + PyObject *func, *res; int result = -1; _Py_IDENTIFIER(__contains__); @@ -5866,13 +5866,7 @@ slot_sq_contains(PyObject *self, PyObject *value) return -1; } if (func != NULL) { - args = PyTuple_Pack(1, value); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } + res = _PyObject_FastCall(func, &value, 1, NULL); Py_DECREF(func); if (res != NULL) { result = PyObject_IsTrue(res); @@ -6225,20 +6219,14 @@ static _Py_Identifier name_op[] = { static PyObject * slot_tp_richcompare(PyObject *self, PyObject *other, int op) { - PyObject *func, *args, *res; + PyObject *func, *res; func = lookup_method(self, &name_op[op]); if (func == NULL) { PyErr_Clear(); Py_RETURN_NOTIMPLEMENTED; } - args = PyTuple_Pack(1, other); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } + res = _PyObject_FastCall(func, &other, 1, NULL); Py_DECREF(func); return res; } |