RFC: Proposal: Deterministic Object Destruction
On Sunday, 4 March 2018 03:00:13 UTC, Chris Angelico wrote:
> This thread is dead. The OP wants to wave a magic wand and say
> "__del__ is now guaranteed to be called immediately",
No "magic" required: Just one line change in the language reference will do it.
> without any explanation
The PEP says it all really: To make the very pythonic RAII idiom available in python.
> - and, from the look of things, without any understanding
> - of what that means for the language
What impact on the _language_ (c.f. interpreter) do you think I have not understood?
It is is 100% backwards compatible with the language. It breaks nothing.
It allows people who want to use the RAII idiom to do so.
It allows people who want to use the "with" idiom to continue do so.
> and the interpreters.
I am well aware of what it will mean for interpreters. For some interpreters it will have zero impact (e.g. CPython) and for some others it would unlikely be economic to make them comply.
The decision here is does python want to be more pythonic, and make itself attractive for resource management applications or does it want to be compromised by some implementations?
> Everyone else is saying "your magic wand is broken". This is not going to go
Well I see a lot of posts that indicate peeps here are more comfortable with
the "with" idiom than the RAII idiom but I have not yet seen a single
linguistic problem or breakage.
As it happens I have used RAII extensively with CPython to manage a debugging environment with complex external resources that need managing very efficiently.
(I would use C++ if starting from scratch because it _guarantees_ the required deterministic destruction whereas python does not)