[Patches] A little optimization in PyObject_Cmp()

Gisle Aas gisle@ActiveState.com
22 Jun 2000 22:23:49 +0200


"M.-A. Lemburg" <mal@lemburg.com> writes:

> Gisle Aas wrote:
> > 
> > Avoid calling PyErr_Occurred() all the time...
> > 
> > Index: Objects/abstract.c
> > ===================================================================
> > RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
> > retrieving revision 2.35
> > diff -u -p -u -r2.35 abstract.c
> > --- Objects/abstract.c  2000/06/18 18:43:14     2.35
> > +++ Objects/abstract.c  2000/06/22 19:27:42
> > @@ -68,7 +68,7 @@ PyObject_Cmp(o1, o2, result)
> >                 return -1;
> >         }
> >         r = PyObject_Compare(o1, o2);
> > -       if (PyErr_Occurred())
> > +       if (r == -1 && PyErr_Occurred())
> 
> Is this documented ? I mean: will all implementations return
> -1 in the error case ?
> 
> (I think this is the case for the core interpreter, but
>  what about extensions ?)

I have now reread what the API docs says about PyObject_Compare(), so
please just forget this one.

Regards,
Gisle