Gabriele Brambilla wrote:

> Hi,
> 
> I have this script

> points = 33750000000

>     for iw in range(points):
>         print iw
> 
> 
> But when I run it it is killed in the for cycle, it doesn't print any
> number:
> 
> [gabriele:~/Desktop/GITcode] gbrambil% python EknotFromKostas.py
> im here
> ../NOBACKUP/heavi3/EX_104189.dat
> pastopens
> Killed
> 
> does it mean that my number of points is too high?

In Python 2 range(points) creates a list. To store only the object 
references in the list (the actual int object takes much more memory) you 
need

>>> 33750000000 * 8
270000000000

Bytes or

>>> _ / 2**30
251.4570951461792

i. e. over 250 GiB of RAM on a 64 bit system.

While you can replace range() with xrange() in Python 2 or switch to Python 
3 where range() is an object

>>> range(33750000000)
range(0, 33750000000)

you should start with much smaller numbers and then extrapolate the expected 
runtime and memory consumption of your script once it does anything useful.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to