[Numpy-discussion] numpy CAPI questions

Lane Brooks lbrooks at MIT.EDU
Sun Oct 19 17:52:50 EDT 2008


Robert Kern wrote:
> On Sun, Oct 19, 2008 at 14:28, Lane Brooks <lbrooks at mit.edu> wrote:
>   
>> 2. Is my reference counting correct?  Do I need to call the
>> PyArray_INCREF() on img?
>>     
>
> Personally, I always need to double-check my refcounting with
> sys.getrefcount() (which, it should be noted, adds its own reference,
> so the correct result for sys.getrefcount(foo()) should be 1). In your
> actual code, do you have anything else in the Py_BuildValue()? If you
> don't, then you don't need to use Py_BuildValue(); you can just return
> img.
>   


Thanks for the great tip on sys.getrefcount().  I understand reference 
counting a whole lot better now after playing with sys.getrefcount() 
function.

Lane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081019/e3925172/attachment.html>


More information about the NumPy-Discussion mailing list