mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Created PyObject_GenericGetIter().
Factors out the common case of returning self.
This commit is contained in:
parent
08801db123
commit
0153826964
10 changed files with 30 additions and 147 deletions
|
|
@ -43,13 +43,6 @@ iter_traverse(seqiterobject *it, visitproc visit, void *arg)
|
|||
return visit(it->it_seq, arg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
iter_getiter(PyObject *it)
|
||||
{
|
||||
Py_INCREF(it);
|
||||
return it;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
iter_iternext(PyObject *iterator)
|
||||
{
|
||||
|
|
@ -106,7 +99,7 @@ PyTypeObject PySeqIter_Type = {
|
|||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
(getiterfunc)iter_getiter, /* tp_iter */
|
||||
PyObject_GenericGetIter, /* tp_iter */
|
||||
(iternextfunc)iter_iternext, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
|
|
@ -223,7 +216,7 @@ PyTypeObject PyCallIter_Type = {
|
|||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
(getiterfunc)iter_getiter, /* tp_iter */
|
||||
PyObject_GenericGetIter, /* tp_iter */
|
||||
(iternextfunc)calliter_iternext, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue