Queue cleanup

John Nagle nagle at animats.com
Sun Sep 5 01:23:44 EDT 2010


On 9/4/2010 6:44 PM, Lawrence D'Oliveiro wrote:
> In message<4c82b097$0$1661$742ec2ed at news.sonic.net>, John Nagle wrote:
>
>>      Personally, I'd like to have reference counting only, an enforced
>> prohibition on loops (backpointers must be weak pointers), RAII,
>> and reliably ordered finalization.
>
> Is there a cheap way of checking at runtime for circular structures?

    It's an interesting technical problem to design a system where
circular references are detected immediately, at the moment
of creation.  However, Python already detects loops during
garbage collection.  If you set

	gc.set_debug(gc.DEBUG_SAVEALL)

all the loops show up in "gc.garbage".

>>      A big advantage of reference counting is that finalization happens
>> in the thread that releases the object, and in the correct order.
>> GC and finalization/destructors do not play well together at all.
>> Microsoft once tried to get the hard cases to work right.  See
>> "managed C++".  Not a happy story.
>
> Thank you for that. Another arrow for my anti-GC quiver. :)

     Unoptimized reference counting, which is what CPython does, isn't
all that great either.  The four big bottlenecks in Python are boxed
numbers, attribute lookups, reference count updates, and the GIL.

				John Nagle




More information about the Python-list mailing list