[issue45026] More compact range iterator

Dennis Sweeney report at bugs.python.org
Fri Aug 27 01:09:59 EDT 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

Is it worth removing the len field as well and lazily using get_len_of_range() as needed?

Then the hot function can look something like:

static PyObject *
rangeiter_next(rangeiterobject *r)
{
    long result = r->start
    if (result < r->stop) {
        r->start += r->step;
        return PyLong_FromLong(result);
    }
    return NULL;
}

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45026>
_______________________________________


More information about the Python-bugs-list mailing list