RFC: Proposal: Deterministic Object Destruction
Dietmar Schwertberger
maillist at schwertberger.de
Sat Mar 3 11:59:12 EST 2018
On 2/28/2018 11:51 PM, ooomzay at gmail.com wrote:
> This PEP proposes that valid python interpreters *must* synchronously destroy objects when the last reference to an object goes out of scope. This interpreter behaviour is currently permitted and exhibited by the reference implementation [CPython], but it is optional.
CPython does *not* guarantee destruction when the object reference goes
out of scope, even if there are no other references.
I would very much appreciate such a deterministic behaviour, at least
with CPython.
I recently had to debug an issue in the matplotlib wx backend (*). Under
certain conditions, the wx device context was not destroyed when the
reference went out of scope. Adding a del to the end of the method or
calling the Destroy method of the context did fix the issue. (There was
also a hidden reference, but avoiding this was not sufficient. The del
was still required.)
(*) https://github.com/matplotlib/matplotlib/issues/10174
Regards,
Dietmar
More information about the Python-list
mailing list