[Numpy-discussion] numpy CAPI questions

David Cournapeau cournape@gmail....
Sun Oct 19 21:12:40 CDT 2008


On Mon, Oct 20, 2008 at 6:52 AM, Lane Brooks <lbrooks@mit.edu> wrote:
>
>
> Thanks for the great tip on sys.getrefcount().  I understand reference
> counting a whole lot better now after playing with sys.getrefcount()
> function.

For debugging purpose, and if you need it in C, you can use the member
a->ob_refcount where a is any valid pointer to a PyObject. This is
more or less the equivalent of sys.getrefcount, but at the C level
(without the +1). The struct member ob_refcount is private and should
not be depended on in "real" code, but I personally like using it when
I am not sure about ref counting.

cheers,

David


More information about the Numpy-discussion mailing list