mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
018016d8e3
commit
5e87749a8e
|
@ -5808,7 +5808,7 @@ slot_sq_length(PyObject *self)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
slot_sq_item(PyObject *self, Py_ssize_t i)
|
slot_sq_item(PyObject *self, Py_ssize_t i)
|
||||||
{
|
{
|
||||||
PyObject *func, *ival = NULL, *args, *retval = NULL;
|
PyObject *func, *ival = NULL, *retval = NULL;
|
||||||
descrgetfunc f;
|
descrgetfunc f;
|
||||||
|
|
||||||
func = _PyType_LookupId(Py_TYPE(self), &PyId___getitem__);
|
func = _PyType_LookupId(Py_TYPE(self), &PyId___getitem__);
|
||||||
|
@ -5834,20 +5834,13 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = PyTuple_New(1);
|
retval = _PyObject_FastCall(func, &ival, 1, NULL);
|
||||||
if (args == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyTuple_SET_ITEM(args, 0, ival);
|
|
||||||
retval = PyObject_Call(func, args, NULL);
|
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
Py_DECREF(args);
|
Py_DECREF(ival);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
Py_XDECREF(ival);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue