MemoryError when list append... plz help

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


(Sorry for top posting):

You are mad! Why on God's earth would you want
to create a list containing 60 MILLION elements ?

What is the use case ? What are you solving ?

You may have 4G of ram, but I very seriously
doubt you have 4G of ram available to Python.

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.

--JamesMills

--
-- "Problems are solved by method"



On Wed, Dec 31, 2008 at 4:02 PM, [BON] <alooha at live.co.kr> wrote:
>
> ======================
> s=[]
> for i in range(11000-1):
>    for j in range(i+1, 11000):
>        ....
>        s.append(((i,j),sim))
> ======================
> above sim is floating type.
> s.append is totally coducted 60,494,500 times.
> but this code raise MemoryError.
>
> My computer has 4G RAM.
> i think it's enough. but it doesn't...
>
> So, i've tested below code.
> ======================
> a=[]
> i=0
> while i<60494500 :
>    a.append(i)
>    i+=1
> ======================
> but this code raise also MemoryError.
>
> How can i resolve this problem?
> please, help...
>
> Regards,
> --
> View this message in context: http://www.nabble.com/MemoryError-when-list-append...-plz-help-tp21227745p21227745.html
> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list