Memory Error while simulating matrix
Slick
slick at asia.com
Tue Mar 26 00:38:03 EST 2002
Hello,
When i execute the code(part of an algorithm code) given below, i get
a MemoryError. The best part was that this ran a couple of time before
it began crashing.
------------------------ code starts here ----------------------
row = [] # list
row = [0] * 1000000 # each row contains million columns
matrix =[] # contains a collection of rows
for i in range(1000): # creating a matix of 1000 rows each
matrix.append(row[:]) # having a million columns
------------------------ code ends here ----------------------
------------------------- error message starts here ------------
Traceback (innermost last):
File "a.py", line 7, in ?
matrix.append(row[:])
MemoryError
------------------------- error message ends here --------------
Is there any way to prevent this error ? other than installing the
pyNum package ?
Any help to prevent this from happening is appriciated.
Thanks in advance
Max
More information about the Python-list
mailing list