[Tutor] Python cashes low integers? How? Where?

Kalle Svensson kalle at lysator.liu.se
Mon Aug 9 09:59:49 CEST 2004


[Dick Moores]
> If I could ask what seems to be a related question: On p. 85 Chun
> says, "Each object has associated with it a counter that tracks the
> total number of references that exist to that object. This number
> simply indicates how many variables are 'pointing to' any particular
> object."  However, he doesn't say how to find this number. Is there
> a way?

Yes.  The number is called a refcount, and can be read with the
function sys.getrefcount.
http://python.org/doc/lib/module-sys.html#l2h-344

Peace,
  Kalle
-- 
http://juckapan.org/~kalle/
http://laxmasteriet.se/04-05/


More information about the Tutor mailing list