Queue cleanup

Aahz aahz at pythoncraft.com
Mon Aug 30 14:47:05 CEST 2010

In article <4c7b279d$0$28650$c3e8da3 at news.astraweb.com>,
Steven D'Aprano  <steve-REMOVE-THIS at cybersource.com.au> wrote:
>On Sun, 29 Aug 2010 17:52:38 -0700, Paul Rubin wrote:
>>Attribution lost:
>>> That's a problem with the CPython API, not reference counting. The
>>> problem is that the CPython API is written at too low a level, beneath
>>> that at which the garbage collector exists, so naturally you have to
>>> manually manage memory.
>> Care to give an example of a reference counted system that's written any
>> other way?
>The complexity of the ref counter is invisible when writing pure Python 
>code, and I believe it is also invisible when writing code in Cython. The 
>difficulty of dealing with ref counts is abstracted away.

That's not completely true.  You know perfectly well that it's almost
trivially easy to leak memory with refcounting, and there are certain
ways in which Python leaks memory invisibly if you don't know how it
works.  One recent example at work was when someone was arguing with me
about whether we were leaking file handles and I had to prove that you
could leak file handles if you didn't clean up exceptions -- but that
cleaning up the exception *did* close the file handles.

(This code was originally written in Python 2.4, and partly because of
this we are making more of a push to use "with"....)

If you're restricting your claim just to the actual management of the
reference counter, you're correct, but it's especially not clear that
your second sentence is so restricted.
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...if I were on life-support, I'd rather have it run by a Gameboy than a
Windows box."  --Cliff Wells

More information about the Python-list mailing list