Garbage collection

Aahz aahz at pythoncraft.com
Mon Feb 18 19:57:02 EST 2008


In article <mailman.937.1203371803.9267.python-list at python.org>,
Ken  <ken at seehart.com> wrote:
>Simon Pickles wrote:
>>
>> For instance, I have a manager looking after many objects in a dict. 
>> When those objects are no longer needed, I use del manager[objectid], 
>> hoping to force the garbage collector to perform the delete.
>>
>> However, this doesn't trigger my overloaded __del__ destructor. Can I 
>> simply rely on the python garbage collector to take it from here?
>   
>Objects are deleted at some undefined time after there are no references 
>to the object.

Assuming we're talking about CPython, objects are deleted immediately
when there are no references to the object.  The problem is that it's
not always obvious when the refcount goes to zero.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of     
indirection."  --Butler Lampson



More information about the Python-list mailing list