[Matrix-SIG] PyArray_Free in arrayobject.c
Mon, 1 Mar 1999 23:01:17 -0600 (EST)
On Mon, 1 Mar 1999, David Ascher wrote:
> > This code admittedly looks a little bit strange. I believe that it
> > should only be called very rarely (at least as originally inteneded)
> > and is supposed to be partnered with the PyArray_As1d and As_2d (or
> > something like that) calls -- the reason for the skipped nd == 3 case
> > is that I had originally planned an As3d function and never got around
> > to implementing it.
I suspected that PyArray_Free was supposed to be partnered with
PyArray_AsXd. I see why there would be an nd == 3 case that would get
skipped. Still, the code there now seems to free a single array of
pointers (exactly what it should do for the n=2 case)
> > The As2d function in particular created a new C-array which isn't
> > referenced by any PyArray objects (so people can do a C-style
> > indexing). The Free function handles freeing this.
This is what I thought it was supposed to do. But, as is, this array of
pointers never gets released because ap->nd != 3, and the code to release
this array of pointers is inside of a conditional branch that requires
ap->nd == 3.
> I can't imagine why PyArray_Reshape, PyArray_Transpose,
> PyArray_Repeat, ... would be using this function, but if they are it
> might indicate something peculiar is going on.
Well, they are indeed being used in these functions. I agree that they
are unnecessary though. Is something peculiar going on?
> BTW - A huge motivating factor of JPython was how frustrated I got
> with all these silly refcount issues when building numpy. I wouldn't
> be surprised if you found some mistakes on that score...
Is there a NumPy for JPython?