summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-19 16:19:42 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-19 16:19:42 (GMT)
commit5e87749a8eec95e277c0d1ec5f40467cefcb9957 (patch)
tree3e212c34c3fc2464fdc00b7b5f2564faedbf3004
parent018016d8e338dc99353b96df2c570bf2fd63fce2 (diff)
downloadcpython-5e87749a8eec95e277c0d1ec5f40467cefcb9957.zip
cpython-5e87749a8eec95e277c0d1ec5f40467cefcb9957.tar.gz
cpython-5e87749a8eec95e277c0d1ec5f40467cefcb9957.tar.bz2
Issue #27128: slot_sq_item() uses fast call
slot_sq_item() now calls _PyObject_FastCall() to avoid the creation of a temporary tuple of 1 item to pass the 'item' argument to the slot function.
-rw-r--r--Objects/typeobject.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ff9f020..364841b 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5808,7 +5808,7 @@ slot_sq_length(PyObject *self)
static PyObject *
slot_sq_item(PyObject *self, Py_ssize_t i)
{
- PyObject *func, *ival = NULL, *args, *retval = NULL;
+ PyObject *func, *ival = NULL, *retval = NULL;
descrgetfunc f;
func = _PyType_LookupId(Py_TYPE(self), &PyId___getitem__);
@@ -5834,20 +5834,13 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
goto error;
}
- args = PyTuple_New(1);
- if (args == NULL) {
- goto error;
- }
-
- PyTuple_SET_ITEM(args, 0, ival);
- retval = PyObject_Call(func, args, NULL);
+ retval = _PyObject_FastCall(func, &ival, 1, NULL);
Py_DECREF(func);
- Py_DECREF(args);
+ Py_DECREF(ival);
return retval;
error:
Py_DECREF(func);
- Py_XDECREF(ival);
return NULL;
}