[Matrix-SIG] PyArray_Free in arrayobject.c

David Ascher da@ski.org
Mon, 1 Mar 1999 16:41:58 -0800 (Pacific Standard Time)


On Mon, 1 Mar 1999, Travis Oliphant wrote:

> While I was looking at the source to write some documentation, I noticed
> that PyArray_Free looks like it won't work as intended.  

I asked Jim Hugunin about it a few months back and submitted a (flawed)
patch suggestion. His answer:

>> 2) Here is PyArray_Free:

> 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.

> The As2d function in particular created a new C-array which isn't
> referenced by any PyArray objects (so people can do a[0][0] C-style
> indexing).  The Free function handles freeing this.  Your new version
> wouldn't do the right thing with 1d arrays (the data area is not
> supposed to be freed by this function).

> 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.

> 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...

--david