file closing

Colin Brown cbrown at metservice.com
Thu May 22 16:25:27 EDT 2003


"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.1053614920.10596.python-list at python.org...
>     [second case]
>     >> file('test.dat','w').write(chr(0)*1000000)
...
> More precisely, it relies on reference counting.  There's no cycle which
> needs to be broken, so CPython's cyclical garbage collection isn't
involved.

Okay... so the reference count for the file handle drops to zero immediately
after execution of this instruction. Does this mean an explicit close is
being
done before the next instruction? If so then the two code snippets are
functionally
identical (with the second being much shorter). Also is the close
synchronous or
asynchronous?

Colin







More information about the Python-list mailing list