[Python-3000] range() issues
Mark Dickinson
dickinsm at gmail.com
Tue Apr 29 22:17:08 CEST 2008
On Tue, Apr 29, 2008 at 10:30 AM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:
> or sizable. I would say "range(n) is a memory efficient substitute
> for [0, 1, ... n-1]" is easier to fit into one's brain that the
> current hodgepodge of exceptions.
>
For what it's worth, I'm -1 on any change that makes range(10**10)
an error. I'd like to be able to write
for i in range(n):
...
without having to stop and worry about whether n is always going
to be small enough to avoid an exception, and what to do if there's
a possibility that n is large. The common case of range should
have a small mental footprint.
Indexing a range object, or taking its length, are surely much rarer
than simply iterating over it; I don't think the problems with indexing
and length are a good reason to impose restrictions on the use
of range as an iterable.
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-3000/attachments/20080429/2fc5ab86/attachment.htm>
More information about the Python-3000
mailing list