Object cleanup

Ben Finney ben+python at benfinney.id.au
Wed May 30 23:04:45 EDT 2012


Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

> The destructor doesn't get called into the last reference is gone.

And it's important to note that the destructor doesn't get called
*immediately* that happens; rather, the destructor will be called *some
time after* the last reference to the object is gone.

In short: you can't force Python to invoke the destructor at any
particular time, and hence your code shouldn't assume that it will
happen at any particular time.

-- 
 \       “Timid men prefer the calm of despotism to the boisterous sea |
  `\                                    of liberty.” —Thomas Jefferson |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list