[Python-3000] range() issues
Mark Dickinson
dickinsm at gmail.com
Tue Apr 29 23:09:48 CEST 2008
On Tue, Apr 29, 2008 at 4:30 PM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:
> 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.
>
Maybe. But the answer is often going to be yes, if it's a choice between
me spending some number of hours translating everything to C, or just
leaving my computer do the work (however inefficiently) while I do
something else.
These numbers aren't ridiculously large. I just tried
for i in range(2**31): pass
on my (32-bit) laptop: it took 736.8 seconds, or about 12 and a bit minutes.
(An aside: in contrast,
for i in range(2**31-1): pass
took only 131.1 seconds; looks like there's some potential for optimization
here....)
Put another way: range(n) currently works, in Py3k, for n > sys.maxsize.
What's the rationale for breaking that?
extention (combined with a 64-bit OS) may be a good idea if you
> routinely iterate over huge datasets.
>
Well, huge datasets (large time *and* space requirements) don't really
come into it for my typical use-cases: just long-running processes.
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-3000/attachments/20080429/bf4d32d0/attachment-0001.htm>
More information about the Python-3000
mailing list