[Numpy-discussion] Fix to #789 maybe not right.

Charles R Harris charlesr.harris@gmail....
Wed May 21 22:43:54 CDT 2008


On Wed, May 21, 2008 at 9:32 PM, Travis E. Oliphant <oliphant@enthought.com>
wrote:

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

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080521/b3300e76/attachment.html 


More information about the Numpy-discussion mailing list