From: Alf P. Steinbach on 22 Apr 2010 01:48 * Lawrence D'Oliveiro: > In message <4bc9aadb$1(a)dnews.tpgi.com.au>, Lie Ryan wrote: > >> Since in python nothing is guaranteed about implicit file close ... > > It is guaranteed that objects with a reference count of zero will be > disposed. Only in current CPython. > In my experiments, this happens immediately. Depends what you mean, but even in current CPython destruction of a local can be postponed indefinitely if a reference to the stack frame is kept somewhere. And that happens, for example, when an exception is raised (until the handler completes, but it doesn't necessarily complete for a Very Long Time). Cheers & hth., - Alf
From: Adam Tauno Williams on 22 Apr 2010 05:59 On Thu, 2010-04-22 at 12:53 +1200, Lawrence D'Oliveiro wrote: > In message <4bc9aadb$1(a)dnews.tpgi.com.au>, Lie Ryan wrote: > > Since in python nothing is guaranteed about implicit file close ... > It is guaranteed that objects with a reference count of zero will be > disposed. In my experiments, this happens immediately. A current implementation specific detail. Always close files. Otherwise, in the future, or on a different run-time, your code will break.
From: Lawrence D'Oliveiro on 23 Apr 2010 00:29 In message <mailman.2119.1271898215.23598.python-list(a)python.org>, Chris Rebert wrote: > On Wed, Apr 21, 2010 at 5:53 PM, Lawrence D'Oliveiro wrote: > >> In message <4bc9aadb$1(a)dnews.tpgi.com.au>, Lie Ryan wrote: >> >>> Since in python nothing is guaranteed about implicit file close ... >> >> It is guaranteed that objects with a reference count of zero will be >> disposed. > >> In my experiments, this happens immediately. > > Experiment with an implementation other than CPython and prepare to be > surprised. Any implementation that doesn't do reference-counting is brain-damaged.
From: Steven D'Aprano on 23 Apr 2010 00:49 On Fri, 23 Apr 2010 16:29:46 +1200, Lawrence D'Oliveiro wrote: > Any implementation that doesn't do reference-counting is brain-damaged. Funny, that's exactly what other people say about implementations that *do* use reference counting. -- Steven
From: Steven D'Aprano on 23 Apr 2010 18:04 On Fri, 23 Apr 2010 13:19:41 +0200, Alf P. Steinbach wrote: > But for a literal context-free interpretation e.g. the 'sys.getrefcount' > function is not documented as CPython only and thus an implementation > that didn't do reference counting would not be a conforming Python > implementation. Since Jython and IronPython are conforming Python implementations, and Guido has started making policy decisions specifically to support these other implementations (e.g. the language feature moratorium, PEP 3003), I think we can assume that this is a documentation bug. However, a Python implementation that always returned 0 for sys.getrefcount would technically satisfy the word of the documentation, if not the spirit. -- Steven
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: class instance customization Next: Calling a class method |