Facundo Batista <facundobatista <at> gmail.com> writes: > > 2008/4/26, Benjamin Peterson <musiccomposition <at> gmail.com>: .. > What is range()? > > help(range) shows me that range "Returns an iterator that generates > the numbers in the range on demand." >
This is not correct in 3.x: range does not return an iterator. There is an iterator similar to range in itertools: count. I would not mind adding optional step and stop arguments to it. > Ahá! So, as ints are unbound in Python, I could easily do: > > >>> r = range(1,1000000000000000000000) > The problem with supporting this is that len(r) will raise overflow error. It would be nice to get rid of the limitation on len(), but it will be hard and may not be possible to do efficiently. > *If* range() provides me the indexing facility (a nice feature to > have, but in any means core to this function), it should allow me to > index it completely, or at least, to Py_ssize_t. IOW, r[0] should > work, even if r[9999999999999999999) doesn't. > It will be very strange to allow objects for which for x in r is not the same as for i in range(len(r)): x = r[i]. Doing so will lead to hard to detect errors. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com