[Python-3000] range() issues

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Apr 29 22:30:33 CEST 2008


On Tue, Apr 29, 2008 at 4:17 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
..

> 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.

I would say that if it is possible that n exceeds a few hundred
million, it is a good idea to pause and think whether you want to have
this loop implemented in Python to begin with.  Numpy or a custom C
extention (combined with a 64-bit OS) may be a good idea if you
routinely iterate over huge datasets.


More information about the Python-3000 mailing list