[Python-Dev] Re: Re: Object finalization for local (ie
tjreedy at udel.edu
Sat Jun 12 14:02:59 EDT 2004
"Martin v. Löwis" <martin at v.loewis.de> wrote in message
news:40CAF8E0.1030909 at v.loewis.de...
> Certainly. However, I'm uncertain whether you find out, in this finally
> block, what objects require this finally-ization.
I brought up the same point on the parallel thread in c.l.p and got no
response. As I remember, one way to create dangling pointers in C is for a
function to pass out of its scope a pointer to a local about to be freed.
I presume the same is true in C++. To me, a main purpose of ref counting
is to know what *not* to release at function exit.
People who want more agressive cleanup on function exit could perhaps
develop a version of Python that calls a cyclic-junk finalizer *after*
locals are decrefed, as part of the execution of explicit or implicit
'return'. The cyclic-junk finalizer could either be cyclic gc improved to
work with __del__ methods or a separate process that used the current cycle
detection apparatus to find candidates for processing.
Since most people neither need nor want the extra return overhead, this
should be a third-party add-on, a compilation option, or possibly a
built-in decoration like staticmethod.
My naive guess is that this would take a least a person-month. I leave it
to *RAII-in-Python advocates to investigate further.
Terry J. Reedy
*Resource Aquisition Is Initialization, in C++ -- because of auto
destruction of locals.
More information about the Python-Dev