referrers

Diez B. Roggisch deets at nospam.web.de
Wed May 24 05:41:36 EDT 2006


raghu wrote:

> Hi All,
> 
> The sys.getrefcount() is very useful to get the number of references on
> a particular object.
> 
> Is there any companion function to get "who" the referrers are ?
> 
> for e.g.
> 
> global x
> global y
> global z
> 
> 
> x0=24012
> y=x0
> z=x0
> 
> print "ref count ",sys.getrefcount(x0)
> 
> 
> This prints a ref count of 5.
> 
> Basically, I need to know which are the 5 entities who are referring to
> x0 ?
> 
> Is there any way of doing it ?

Look into the gc-module.

Diez



More information about the Python-list mailing list