[Python-Dev] Re: tp_clear return value

"Martin v. Löwis" martin@v.loewis.de
Wed, 09 Apr 2003 22:27:01 +0200


Neil Schemenauer wrote:

> I guess I would have to say overdesign.  I was thinking that tp_clear
> and tp_traverse could somehow be used by things other than the GC.  In
> retrospect that doesn't seem likely or even possible.  The GC has pretty
> specific requirements.
> 
> In retrospect, I think both tp_traverse and tp_clear should have
> returned "void".  

While this is true for tp_clear, tp_traverse is actually more general.
gc.get_referrers uses tp_traverse, for something other than collection.

> That would have made implementing those methods
> easier.  Testing for errors in tp_traverse methods is silly since
> nothing returns an error, and, even if it did, the GC couldn't handle
> it.

Again, gc.get_referrers "uses" this feature. If extending the list 
fails, traversal is aborted. Whether this is useful is questionable,
as the entire notion of "out of memory exception handling" is questionable.

Regards,
Martin