Python 2.0

Donn Cave donn at u.washington.edu
Wed Jun 2 11:28:15 EDT 1999


Yukihiro Matsumoto <matz at netlab.co.jp> writes:
...
| I don't mean real GC does everything ref counting does.  For
| exapmle, with real GC:
|
|   dialog = GUItoolkit.dialog(params)
|   ... do something with the dialog ...
|   dialog = None
|
| will close the dialog at unpredictable timing, which is not
| desirable for everyone.  But I prefer explicit termination of the
| dialog for this case.
|
|   dialog = GUItoolkit.dialog(params)
|   ... do something with the dialog ...
|   dialog.close

You're in good company here, I think the leading lights of the Python
world all prefer explicit termination in these cases.  Ref counting sure
offers a great convenience here, though.  Files close and flush their
buffers, dialogues disappear, all in accordance with their programmatic
lifetime.  I personally will miss this finalization more than any resource
management if reference counting is taken away.

I wonder if reference counts could be maintained at a higher level,
still internal but optional as a complement to GC or whatever.  The
C extension writer could forget about reference counts, unless the
extension's own objects use the option or its functions handle external
objects that might have reference counts - or perhaps a C extension
could choose to use reference counts when its external library routines
have memory allocation issues that can't be integrated with the GC.

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu




More information about the Python-list mailing list