[BON] ha scritto:
==
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
On Tue, 30 Dec 2008 22:02:49 -0800, [BON] 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
[BON]:
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...
Try creating it in a more clean way, here an array of doubles:
from array import array
a = array(d, [0.0]) *
En Wed, 31 Dec 2008 06:34:48 -0200, Steven D'Aprano
st...@remove-this-cybersource.com.au escribió:
Each time you are appending to the list, you append a tuple:
((i, j), sim)
where sim is a float and i and j are ints. How much memory does each of
those take?
sys.getsizeof( ((0, 1), 1.1) )
://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
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
--
http://mail.python.org/mailman/listinfo/python
On Wed, Dec 31, 2008 at 4:17 PM, James Mills
prolo...@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