[Python-Dev] del and tp_dealloc in the IO lib (original) (raw)

Curt Hagenlocher curt at hagenlocher.org
Fri Jan 23 02:42:29 CET 2009


On Thu, Jan 22, 2009 at 5:22 PM, Giovanni Bajo <rasky at develer.com> wrote:

On Mon, 19 Jan 2009 01:38:18 +0000, Gregory P. Smith wrote:

I regularly point out in code reviews that the very convenient and common idiom of open(name, 'w').write(data) doesn't guarantee when the file will be closed; its up to the GC implementation details. Which, to me, sounds like "please, don't assume that bytes are 8-bits wide; this depends on implementation details of your CPU".

I think it's a lot more like "please, don't assume that there's a Global Interpreter Lock" -- something that the implementation shouldn't change without good reason and sufficient warning, but which isn't actually part of the language specification. And of course, such advice always carries more weight for code that's intended to be reusable than it does for code that has little chance of escaping the application it's in.

-- Curt Hagenlocher curt at hagenlocher.org



More information about the Python-Dev mailing list