[Tutor] numpy memory muncher

Lloyd Kvam lkvam at venix.com
Mon Nov 13 14:17:54 CET 2006


On Sat, 2006-11-11 at 15:40 -0500, Joel Levine wrote:
> I'm using, perhaps misusing numpy which is eating up the memory and,
> eventually crashing my program.

OK.  that's a small enough piece of code to figure things out.

One quick suggestion, for looping variables xrange avoids creating a
real list.  It provides a lazy evaluation for those cases where you
never need the whole range-list to exist as an entity.

> 
> Isolating it, the following piece of code continually eats memory.  Is it my program or what ...? 
> Thanks
> Joel Levine
> 
> Using Mac OSX 10.4.7
> Not clear on versions:  Appears to be 0.9.8 with py2.4
> 
> -----------------
> 
> from numpy import *
> 
> a=zeros((2000,100),float)
> while True:
>     for row in range(2000):
>         for col in range(100):
>             x=a[row,col]
>             #if x!=0: print "?"
>     
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:  603-653-8139
fax:    320-210-3409



More information about the Tutor mailing list