[Python-Dev] Re: tp_clear return value (original) (raw)

Jeremy Hylton jeremy@zope.com
10 Apr 2003 15:13:12 -0400


On Thu, 2003-04-10 at 14:09, Tim Peters wrote:

I'm not suggesting adding setjmp/longjmp to the Python language <0.9 wink>. I'm suggesting using them for two specific and obscure gc module callbacks that aren't normally used (most of the gc module callbacks wouldn't use setjmp/longjmp); in return, mounds of frequently executed code like

...

could become the simpler and faster

...

Sure sounds good to me.

If traverse worked this way, the traverse and clear slots and a part of the dealloc slot become almost identical. The take all PyObject * members in the struct and perform some action on them if they are non-NULL. dealloc performs a DECREF. clear performs a DECREF + assign NULL. traverse calls visit. It sure makes it easy to verify that each is implemented correctly. It would be cool if there were a way to automate some of the boilerplate.

Jeremy