[Python-Dev] PyFAQ: thread-safe interpreter operations

Aahz aahz at pythoncraft.com
Mon Nov 27 17:43:23 CET 2006

On Mon, Nov 27, 2006, Jason Orendorff wrote:
> Way back on 11/22/06, "Martin v. L?wis" <martin at v.loewis.de> wrote:
>> Nick Coghlan schrieb:
>>> Martin v. L?wis wrote:
>>>> I personally consider it "good style" to rely on implementation details
>>>> of CPython;
>>> Is there a 'do not' missing somewhere in there?
>> No - I really mean it. I can find nothing wrong with people relying on
>> reference counting to close files, for example. It's a property of
>> CPython, and not guaranteed in other Python implementations - yet it
>> works in a well-defined way in CPython. Code that relies on that feature
>> is not portable, but portability is only one goal in software
>> development, and may be irrelevant for some projects.
> It's not necessarily future-portable either.  Having your software not
> randomly break over time is relevant for most nontrivial projects.

We recently had this discussion at my day job.  We ended up agreeing
that using close() was an encouraged but not required style, because to
really avoid breakage we'd have to go with a full-bore try/except style
for file handling, and that would require too many changes (especially
without upgrading to 2.5, and we're still using 2.2/2.3).
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Usenet is not a democracy.  It is a weird cross between an anarchy and a

More information about the Python-Dev mailing list