Ref Count Checking

Ignacio Vazquez-Abrams ignacio at openservices.net
Sat Aug 25 14:28:52 EDT 2001


On Sat, 25 Aug 2001, Robin Becker wrote:

> As part of an extension debugging exercise I printed refcounts
> relating to the structure
> ('a1', {'z1': 'az1'}, ['b1', ('c1', {'y1': 'ay1'}, ['d1'], None), 'e1'], None)
> either created directly in Python or by my extension.
>
>
> An earlier pass revealed values of decrementing values
> for the None output from the extension (it was stealing a None).
> After Correcting I'm still getting differences.
> In particular the strings az1, ay1, b1, c1, d1, e1 seem to have counts from the
> extension which are 3 lower than from the python version.
>
> Is there any way to deduce what the python count should be?
> I'm assuming that a string like az1 is reasonably unique so there
> shouldn't be any question of a library reference.

Your extension is probably still using a borrowed reference and not
incrementing its refcount. Have a look at
http://www.python.org/doc/current/api/api.html and note which functions return
borrowed references and which return new references.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>






More information about the Python-list mailing list