[Python-checkins] python/dist/src/Objects object.c,2.214,2.215
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Mar 21 12:01:47 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5564
Modified Files:
object.c
Log Message:
Add identity shortcut to PyObject_RichCompareBool.
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.214
retrieving revision 2.215
diff -C2 -d -r2.214 -r2.215
*** object.c 27 Jan 2004 20:17:54 -0000 2.214
--- object.c 21 Mar 2004 17:01:44 -0000 2.215
***************
*** 872,878 ****
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
{
! PyObject *res = PyObject_RichCompare(v, w, op);
int ok;
if (res == NULL)
return -1;
--- 872,888 ----
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
{
! PyObject *res;
int ok;
+ /* Quick result when objects are the same.
+ Guarantees that identity implies equality. */
+ if (v == w) {
+ if (op == Py_EQ)
+ return 1;
+ else if (op == Py_NE)
+ return 0;
+ }
+
+ res = PyObject_RichCompare(v, w, op);
if (res == NULL)
return -1;
More information about the Python-checkins
mailing list