[Python-Dev] __del__ and tp_dealloc in the IO lib

Guido van Rossum guido at python.org
Fri Jan 23 16:27:32 CET 2009


On Fri, Jan 23, 2009 at 2:57 AM, Giovanni Bajo <rasky at develer.com> wrote:
> I miss to understand why many Python developers are so fierce in trying
> to push the idea of cross-python compatibility (which is something that
> does simply *not* exist in real world for applications) or to warn about
> rainy days in the future when this would stop working in CPython. I
> would strongly prefer that CPython would settle on (= document) using
> reference counting and immediate destruction so that people can stop
> making their everyday code more complex with no benefit. You will be
> losing no more than an open door that nobody has entered in 20 years,
> and people would only benefit from it.

You are so very wrong, my son. CPython's implementation strategy
*will* evolve. Several groups are hard at work trying to make a faster
Python interpreter, and when they succeed, everyone, including you,
will want to use their version (or their version may simply *be* the
new CPython).

Plus, you'd be surprised how many people might want to port existing
code (and that may include code that uses C extensions, many of which
are also ported) to Jython or IronPython.

Your mistake sounds more like "nobody will ever want to run this on
Windows, so I won't have to use the os.path module" and other
short-sighted ideas. While you may be right in the short run, it may
also be the death penalty for a piece of genius code that is found to
be unportable.

And, by the way, "for line in open(filename): ..." will continue to
work. It may just not close the file right away. This is a forgivable
sin in a small program that opens a few files only. It only becomes a
program when this is itself inside a loop that loops over many
filenames -- you could run out of file descriptors.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list