[Numpy-discussion] Fix to #789 maybe not right.
Charles R Harris
Wed May 21 22:43:54 CDT 2008
On Wed, May 21, 2008 at 9:32 PM, Travis E. Oliphant <firstname.lastname@example.org>
> Charles R Harris wrote:
> > Really, all the increments and decrements should be inside
> > PyArray_FromArray, but calls to this function are scattered all over.
> I don't understand what you mean by this statement. All functions
> that return an object and take a PyArray_Descr object steal a reference
> to the descriptor (even if it fails). That's the rule.
Why should it not increment the reference itself? Note that calls to this
function are normally preceded by incrementing the reference, probably
because one wants to keep it around. I think it would be clearer to have the
rule: you increment it, you decrement it. That way everything is in one
obvious place and you don't have to concern yourself with what happens
inside PyArray_FromArray. Functions with side effects are almost always a
bad idea and lead to bugs in practice.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion