[Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 10 05:11:04 CEST 2005

Jim Jewett wrote:

> If you're talking specific object instances, then the user is the 
> only one (outside of the Garbage Collection system) who has a 
> chance of knowing whether the rest of the iterator will be needed
> later.

Indeed. He *does* know whether he will want the iterator
again later. He *doesn't* know whether it will require
finalization when he is eventually done with it, and
failing to do so if needed will cause obscure bugs.
Also, not needing it again is the overwhelmingly commoner
use case.

My conclusion is that finalization should be the default,
with a way of explicitly overriding it when necessary.

> If there are no remaining references, then garbage collection is the
> answer, and maybe we just need to make it more aggressive.  If
> there are remaining references, then maybe the user is wrong about
> being done.

Or maybe he's not wrong, and due to the way things are
coded, the reference happens to hang around a little
longer than strictly needed.

If garbage collection were sufficient, we'd be relying
on it to close our files in the first place, and this
whole thread would never have gotten started.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list