watching the number of references to an object

Philip Swartzleonard starx at pacbell.net
Sun Feb 17 23:13:11 CET 2002


Courageous || Thu 14 Feb 2002 09:30:48a:

> On Thu, 14 Feb 2002 15:50:04 -0000, "Paul Brian"
> 
>>Dear all,
>>
>>Does anyone know how to monitor the references pointing to an instance
>>of an object?
> 
> In addition to the other answers, please note that the number of
> referrers will often be 1 higher than what you expect: the function
> for getting the references itself temporarily grabs a reference,
> IIRC.

Hm, it seems it would have to be this way to handle unbound object. E.g.

>>> sys.getrefcount( newfoo() )
1

-- 
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com



More information about the Python-list mailing list