index all instances by id - a memory leak?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Oct 2 01:45:01 EDT 2008
On Wed, 01 Oct 2008 21:54:26 -0700, Dan Barbus wrote:
> def __del__(self):
> Item._count -= 1
> # Should I do something here to delete the instance?
> # Will this ever be called if the instance is in a static
> dictionary?
Don't use the `__del__()` method. It is not reliable as there are almost
no guarantees when or if at all it will be called. But its sole
existence may be the cause that objects of that class can't be garbage
collected. Read the documentation of `__del__()` for details.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list