Computer Science question (python list is slow with my cruddy algorithm )

Gerhard Häring gerhard.haering at gmx.de
Fri Aug 23 11:03:56 CEST 2002


* Mr. Neutron <nicktsocanos at charter.net> [2002-08-23 04:39 -0400]:
> Hi,
> I am working on a program that uses a list of lists
> 
> MyList = [ [0] * 32767 for i in range(32767) ]

Do you just want a 2D-array of this size? I'd suppose Numeric has a fast
array implementation.

Btw. on my 32-bit machine, your array would take

>>> 32768**2 * 4L
4294967296L

4 Gigabytes of memory, so do you /really/ need such a large array?

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))




More information about the Python-list mailing list