MemoryError under 2.2b1

Michael Abbott michael at rcp.co.uk
Fri Nov 2 07:29:52 EST 2001


"wtr" <wtri at wtresearch.de> wrote in news:1004688073.78898 at lix-049dz-
008.inside.impress.com:

> The following little script ends in a MemoryError
> 
> hello world!
> Traceback (most recent call last):
>   File "C:/Python22/HelloWorld.py", line 4, in ?
>     for j in range(99999999,1000000001):
> MemoryError
> 
> There seems to be a strange dependancy between the two range parameters;
> ranges (99999999,100000000) and (999999999,1000000099) work.

Well,

1000000001 - 99999999 = 900000002
100000000 - 99999999 = 1
1000000099 - 999999999 = 100

Another clue: range() allocates the entire list before returning (you might 
prefer to use xrange() if appropriate).

Allocating a list containing 900000002 entries uses at least 3.6GB.  If 
your machine could handle this I'd be mightily impressed!



More information about the Python-list mailing list