Hi again, I tried xrange, but I got an error telling me that my integer was too big for a C long.
Clearly, xrange in Py2 is not capable of dealing with Python (that is, possibly very long) integers. I am raising this because, (a) IF xrange in Py3 is a simple "port" from Py2, then it won't handle Python integers either. AND (b) IF xrange in Py3 is intended to be equivalent to range (which, even in Py2, does handle Python integers) THEN It could be argued that xrange in Py3 needs some attention from the developer(s). Stephen Tucker. On Thu, Mar 2, 2023 at 6:24 PM Jon Ribbens via Python-list < python-list@python.org> wrote: > On 2023-03-02, Stephen Tucker <stephen_tuc...@sil.org> wrote: > > The range function in Python 2.7 (and yes, I know that it is now > > superseded), provokes a Memory Error when asked to deiliver a very long > > list of values. > > > > I assume that this is because the function produces a list which it then > > iterates through. > > > > 1. Does the range function in Python 3.x behave the same way? > > No, in Python 3 it is an iterator which produces the next number in the > sequence each time. > > > 2. Is there any equivalent way that behaves more like a for loop (that > is, > > without producing a list)? > > Yes, 'xrange' in Python 2 behaves like 'range' in Python 3. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list