[Matrix-SIG] Numeric semantics question....
Neel Krishnaswami
neel@cswv.com
Tue, 22 Jun 1999 10:20:42 -0400
Hi,
I wanted to confirm that if I assign a subsequence of an array object, the
entire array is kept in memory. That is, if I wrote some code like this:
-*-*-*-
import Numeric
def memory_waster():
x = Numeric.zeros((1000000,1), Numeric.Float)
return x[1]
def hose_system(n):
a = []
for i in range(n):
a.append( memory_waster() )
return a
x = hose_system(500)
-*-*-*-
Numeric would try to allocate memory for 500 million floats, right?
Does making the following change correctly get around the problem?
def memory_waster():
x = Numeric.zeros((1000000,1), Numeric.Float)
return copy.copy(x[1])
I've tried it and it seems to work, but I'd appreciate advice about
the subtleties from anyone more experienced than I.
--
Neel Krishnaswami
neelk@cswv.com