Reference counts
Martin von Loewis
loewis at informatik.hu-berlin.de
Thu May 24 12:15:30 EDT 2001
Helen Dawson <helend at accessone.com> writes:
> I understand that the objects for numbers from 0 to 100 are shared,
> but I find it unlikely that there are actually 1495 references to zero,
> and 70 to 15. Zero is a popular number, but 1495? These results
> are typical for absolutely nothing happening in Python
Others have already guessed that you must have used some large
application, e.g. Pythonwin. Note that every occurrence of 0 in a
python module that has been imported will add to the reference count.
If you want to track all the references, I recommend the patch
http://sourceforge.net/tracker/?func=detail&aid=402925&group_id=5470&atid=305470
There, you'd do
print gc.getreferents(0)
That works for Python 2.x only, of course.
Regards,
Martin
More information about the Python-list
mailing list