[Python-checkins] cpython: Issue #27128: slot_sq_item() uses fast call
victor.stinner
python-checkins at python.org
Fri Aug 19 12:53:54 EDT 2016
https://hg.python.org/cpython/rev/6eb586b85fa1
changeset: 102775:6eb586b85fa1
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Aug 19 18:19:42 2016 +0200
summary:
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.
files:
Objects/typeobject.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5808,7 +5808,7 @@
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 @@
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;
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list