[Python-Dev] Re: DEBUG_SAVEALL feature for gc not in 2.0b1?

Skip Montanaro skip@mojam.com (Skip Montanaro)
Fri, 1 Sep 2000 21:03:51 -0500 (CDT)


    Neil> On Fri, Sep 01, 2000 at 11:47:59PM +0200, Vladimir Marangozov wrote:
    >> By putting them in gc.collected_garbage. The next collect() should be
    >> able to empty this list if the DEBUG_SAVEALL flag is not set. Do you
    >> see any problems with this?

    Neil> I don't really see the point.  If someone has set the SAVEALL flag
    Neil> then they are obviously debugging a program.  I don't see much
    Neil> point in the GC cleaning up this garbage.  The user can do it if
    Neil> they like.

Agreed.

    Neil> I have an idea for an alternate interface.  What if there was a
    Neil> gc.handle_garbage hook which could be set to a function?  The
    Neil> collector would pass garbage objects to this function one at a
    Neil> time.  If the function returns true then it means that the garbage
    Neil> was handled and the collector should not call tp_clear.  These
    Neil> handlers could be chained together like import hooks.  The default
    Neil> handler would simply append to the gc.garbage list.  If a
    Neil> debugging flag was set then all found garbage would be passed to
    Neil> this function rather than just uncollectable garbage.

    Neil> Skip, would a hook like this be useful to you?

Sounds too complex for my feeble brain... ;-)

What's the difference between "found garbage" and "uncollectable garbage"?
What sort of garbage are you appending to gc.garbage now?  I thought by the
very nature of your garbage collector, anything it could free was otherwise
"uncollectable".

S