Class and instance related questions.

Dave Angel davea at davea.name
Fri Jan 24 18:58:43 EST 2014


 Asaf Las <roegltd at gmail.com> Wrote in message:
> On Friday, January 24, 2014 10:45:30 PM UTC+2, Chris Angelico wrote:
>> On Sat, Jan 25, 2014 at 7:32 AM, Asaf Las <r.... at gmail.com> wrote:
>> > On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote:
>> 
>> >> It's possible to unbind the name, but every instance retains a
>> >> reference to its class, so the class itself won't disappear until
>> >> there are no instances left of it.
>> >> ChrisA
>> 
>> > That is interesting. Is it also reference count mechanism or something else?
>> 
>> Yes. [1]
>> 
>> ChrisA
>> 
>> [1] Within the bounds of the question asked, I think a simple "Yes" is
>> more useful here than a long and detailed explanation of the many
>> Pythons and how not all of them refcount at all. Consider this
>> footnote my apology to the experts who would otherwise feel that I'm
>> majorly misleading the OP. Sorry.
> 
> Chris, i like answers which open doors to my curiosity :-)
> yet i should spend my credits very carefully :-)
> 
Rather than dwelling on reference counting,  which is just one
 mechanism for identifying and disposing of objects,  it's usually
 more fruitful to consider what it means to be unreferenced.
 

The usual term is "reachable. "  If an object cannot be reached by
 following some chain of references,  starting from a small list
 of kernel items,  then it should be freed. The cheap way of
 noticing some such objects is by noticing the reference count go
 to zero. That's not enough,  however,  so you also need to
 periodically run a sweep type of garbage collector. See if you
 can guess why reference count alone is inadequate.
 

The CPython system uses both of these,  but other implementations
 do not. I believe that I've heard that the jython system does
 nothing at all, just letting the Java runtime handle it.
 


-- 
DaveA




More information about the Python-list mailing list