Why no open(f, "w").write()?

Donn Cave donn at drizzle.com
Thu May 30 00:09:07 EDT 2002


Quoth Isaac To <kkto at csis.hku.hk>:
...
| Garbage collection is for collecting memory.  So for memory matters, you can
| (and actually, must) give up the control to the garbage collector.  For
| anything else, you *must* do it explicitly.  Surely you shouldn't lock a
| mutex and remove the reference to the mutex, hoping that the garbage
| collector will unlock it quickly enough.

You're describing a language other than C Python.  In C Python, you
*may* close files and rely on other kinds of finalizations through
the reference counting garbage collector, and the result is as timely
as if you did it explicitly.  That's finalization as it ought to be,
and it's a shame that other languages compromise on that.  Lots of
people don't think it's important, but then the majority of programmers
think it's OK that their programming language requires them to keep
track of memory in the same way.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list