Object Reference?
Chris S.
chrisks at NOSPAMudel.edu
Fri Aug 6 21:38:39 EDT 2004
More information about the Python-list mailing list
Fri Aug 6 21:38:39 EDT 2004
- Previous message (by thread): Object Reference?
- Next message (by thread): [py2exe.i18n] English works, German works, but not French. What do I miss?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Gandalf wrote: > Yes, Python figures out when to delete an object, based on its reference > count. But Python only counts the references. It keeps track of the > number of references for the object. It does not know where the > reference is located in memory. The short answer is that you cannot get > this information effectively. The gc module has methods that list an object's referrers and referents. Although you're correct in that we're unable to access the total number of references since duplicate references are not counted. For instance import gc a=[1,2,3] b=[a,a,a,a] print gc.get_referrers(a) would only print out one instance of b, even though it references 'a' four times. However, this only seems to apply for direct references, so the total number of references can be determined by scanning all referrers and counting the duplicate ids.
- Previous message (by thread): Object Reference?
- Next message (by thread): [py2exe.i18n] English works, German works, but not French. What do I miss?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list