[Python-3000] PEP: Eliminate del (original) (raw)

Michael Bayer mike_mp at zzzcomputing.com
Fri May 4 18:45:07 CEST 2007


On May 4, 2007, at 10:33 AM, Giovanni Bajo wrote:

On 5/4/2007 4:21 PM, Michael Bayer wrote:

why not encapsulate the "proper" weakref-based approach in an easy- to-use method such as "close()" ? that way nobody has to guess how to follow this pattern. Because the idea is that the callback of the weakref will NOT hold a reference to the object being destroyed, but only to the resources that need to be deallocated (that is, to the objects bound as attributes of the object).

a close() method on a class is first bound to the class, not any
particular self. the Python runtime could detect this and create the
appropriate callable/weakref scenario behind the scenes; not even
binding close() to the self in the usual way. obviously it cant
be a pure python solution, it would have to be a specific runtime
supported idea (the same way metaclass or any other magic
attribute is supported).

i just dont understand why such an important feature would have to be
relegated to just a "recipe". i think thats a product of the notion
that "implicit finalizers are bad, use try/finally". thats not
really valid for things like buffers that flush and database/network
connections that must be released when they fall out of scope.



More information about the Python-3000 mailing list