[Numpy-discussion] how does numpy handle views and garbage collection?
Wed Sep 30 06:43:05 CDT 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:
pts = np.column_stack((Xquad, Yquad, Zquad, np.ones(Zquad.shape)))
transpts = np.dot(transmat, pts.T).T
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?
More information about the NumPy-Discussion