On Thu, Jan 22, 2009 at 5:22 PM, Giovanni Bajo <ra...@develer.com> wrote: > CPython will always use reference counting and thus have a simple and > clear GC criteria that can be exploited to simplify the code.
Believe this at your own peril. Once, CPython didn't have GC at all (apart from refcounting). Now it does. There are GC techniques that delay DECREF operations until it's more convenient. If someone finds a way to exploit that technique to save 10% of execution time it would only be right to start using it. You *can* assume that objects that are no longer referenced will *eventually* be GC'ed, and that GC'ing a file means flushing its buffer and closing its file descriptor. You *cannot* assume that objects are *immediately* GC'ed. This is already not always true in CPython for many different reasons, like objects involved in cycles, weak references, or tracebacks saved with exceptions, or perhaps profiling/debugging hooks. If we found a good reason to introduce file objects into some kind of cycle or weak reference dict, I could see file objects getting delayed reclamation even without changes in GC implementation. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com