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

Travis E. Oliphant oliphant@enthought....
Thu May 22 00:16:55 CDT 2008


Charles R Harris wrote:
>
> I  agree with all that, which is why I'm not advocating a change. But 
> it does raise the bar for working with the C code and I think the 
> current case is an example of that.
>
Yes it does.  I also agree that reference counting is the hardest part 
of coding with the Python C-API. 
>
>
>     > I think it would be clearer to have the rule: you increment it, you
>     > decrement it.
>     Maybe, but Python's own C-API doesn't always follow that rule,
>     there are
>     functions that steal references.   Remember, PyArray_Descr was
>     retrofitted as a Python Object.  It didn't use to be one.   This steal
>     rule was the cleanest I could come up with --- i.e. it wasn't an idle
>     decision.
>
>
> I realize that Python does this too, I also note that getting 
> reference counting right is one of the more difficult aspects of 
> writing Python extension code. The more programmers have to know and 
> keep in mind, the more likely they are to make mistakes.
>
Agreed.

-teo




More information about the Numpy-discussion mailing list