[Numpy-discussion] how does numpy handle views and garbage collection?
Chris Colbert
sccolbert at gmail.com
Wed Sep 30 07:43:05 EDT 2009
Lets say I have function that applies a homogeneous transformation
matrix to an Nx3 array of points using np.dot.
since the matrix is 4x4 I have to add a 4 column of ones to the array
so the function looks something like this:
def foo():
<--snip-->
pts = np.column_stack((Xquad, Yquad, Zquad, np.ones(Zquad.shape)))
transpts = np.dot(transmat, pts.T).T
return transpts[:,:3]
Since i'm returning just the view of the array, I imagine python
doesnt garbage collect transpts once the function returns and falls
out of scope (because numpy has increfed it in the view operation?).
So in essence, I still have that whole column of ones hanging around
wasting memory, is that about right?
Cheers,
Chris
More information about the NumPy-Discussion
mailing list