[Python-Dev] lookdict

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Fri, 1 Sep 2000 23:16:23 +0200 (CEST)


Guido van Rossum wrote:
> 
> > Right. I was too fast. There is some speedup due to the string
> > specialization. I'll post a patch to SF with some more tweaks
> > of this implementation. Briefly:
> > 
> > - do not call PyErr_Clear() systematically after PyObject_Compare();
> >   only if (!error_restore && PyErr_Occurred())
> 
> What do you mean?  The lookdict code checked in already checks
> PyErr_Occurrs().

Was fast again. Actually PyErr_Clear() is called on PyErr_Occurred().
PyErr_Occurred() is called systematically after PyObject_Compare()
and it will evaluate to true even if the error was previously fetched.

So I mean that the test for detecting whether a *new* exception is
raised by PyObject_Compare() is (!error_restore && PyErr_Occurred())
because error_restore is set only when there's a previous exception
in place (before the call to Object_Compare). And only in this case
we need to clear the new error.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252