MemoryError when list append... plz help

James Mills prologic at shortcircuit.net.au
Wed Dec 31 01:23:49 EST 2008


On Wed, Dec 31, 2008 at 4:17 PM, James Mills
<prologic at shortcircuit.net.au> wrote:
> I have no idea how many bytes of memory
> storing each element of a list consumes
> let alone each float object, but I assure you
> it's not going to be anywhere near that of
> 60494500 4-bytes spaces (do floats in C
> normally consume 4 bytes) in C.

Just creating a list of this many elements
consumes 60% of my desktops RAM.
YOu _SHOLD NOT_ be doing this.

>>> L = list(xrange(N))
>>> len(L)
60494500
>>> L[10000]
10000

ps stats:

32351 jmills    20   0  962m 610m 1356 S  0.0 60.6   0:03.36 python

It takes several seconds to create this list
and several minutes for the Python interpreter
to shutdown and deallocate all the memory.

--JamesMills



More information about the Python-list mailing list