mirror of https://github.com/python/cpython
Remove the next() method -- one is supplied automatically by
PyType_Ready() because the tp_iternext slot is set. Also removed the redundant (and expensive!) call to raise StopIteration from rangeiter_next().
This commit is contained in:
parent
2147df748f
commit
86d593e110
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/* Range object implementation */
|
/* Range object implementation */
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
@ -251,16 +250,9 @@ rangeiter_next(rangeiterobject *r)
|
||||||
{
|
{
|
||||||
if (r->index < r->len)
|
if (r->index < r->len)
|
||||||
return PyInt_FromLong(r->start + (r->index++) * r->step);
|
return PyInt_FromLong(r->start + (r->index++) * r->step);
|
||||||
PyErr_SetObject(PyExc_StopIteration, Py_None);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef rangeiter_methods[] = {
|
|
||||||
{"next", (PyCFunction)rangeiter_next, METH_NOARGS,
|
|
||||||
"it.next() -- get the next value, or raise StopIteration"},
|
|
||||||
{NULL, NULL} /* sentinel */
|
|
||||||
};
|
|
||||||
|
|
||||||
static PyTypeObject Pyrangeiter_Type = {
|
static PyTypeObject Pyrangeiter_Type = {
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
PyObject_HEAD_INIT(&PyType_Type)
|
||||||
0, /* ob_size */
|
0, /* ob_size */
|
||||||
|
@ -291,6 +283,5 @@ static PyTypeObject Pyrangeiter_Type = {
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
(getiterfunc)rangeiter_getiter, /* tp_iter */
|
(getiterfunc)rangeiter_getiter, /* tp_iter */
|
||||||
(iternextfunc)rangeiter_next, /* tp_iternext */
|
(iternextfunc)rangeiter_next, /* tp_iternext */
|
||||||
rangeiter_methods, /* tp_methods */
|
0, /* tp_methods */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue