Reference Tracking

Ganesan R rganesan at
Tue Apr 15 06:29:53 CEST 2003

>>>>> "Alex" == Alex Martelli <aleax at> writes:

> Note that any Python function call always passes VALUES -- i.e.
> there is no difference between your call to sys.getrefcount in
> the above snippet and one that directly does sys.getrefcount(1).
> In either case, it's the VALUE (1) that you're asking info about;
> it makes no difference HOW you obtain the value to pass (I guess
> this is probably already clear to you, but, just in case...).

Then, I find this confusing

Python 2.2.1 (#1, Jul 29 2002, 23:15:49) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gc
>>> a = "hello world"
>>> gc.get_referrers(a)
[{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', 'gc': <module 'gc' (built-in)>, '__doc__': None, 'a': 'hello world'}]
>>> b = "hello world"
>>> gc.get_referrers(a)
[{'a': 'hello world', 'b': 'hello world', 'gc': <module 'gc' (built-in)>, '__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None}]
>>> gc.get_referrers("hello world")
[('hello world', None)]

Why am I getting a different list for the last call? 


Ganesan R

More information about the Python-list mailing list