slot_tp_iter() now uses fast call

Issue #27128: slot_tp_iter() now calls _PyObject_FastCall() to avoid a
temporary empty tuple.
This commit is contained in:
Victor Stinner 2016-08-19 18:41:02 +02:00
parent 20a3007a8d
commit 6911267615
1 changed files with 3 additions and 6 deletions

View File

@ -6264,16 +6264,13 @@ slot_tp_iter(PyObject *self)
Py_TYPE(self)->tp_name); Py_TYPE(self)->tp_name);
return NULL; return NULL;
} }
if (func != NULL) { if (func != NULL) {
PyObject *args; res = _PyObject_FastCall(func, NULL, 0, NULL);
args = res = PyTuple_New(0);
if (args != NULL) {
res = PyObject_Call(func, args, NULL);
Py_DECREF(args);
}
Py_DECREF(func); Py_DECREF(func);
return res; return res;
} }
PyErr_Clear(); PyErr_Clear();
func = lookup_method(self, &PyId___getitem__); func = lookup_method(self, &PyId___getitem__);
if (func == NULL) { if (func == NULL) {