RichCompare and RichCompareBool

Terry Reedy tjreedy at udel.edu
Mon Mar 2 20:54:09 CET 2009


Aaron Brady wrote:
> Hi,
> 
> In the source for 3.0.1, PyObject_RichCompareBool seems to perform an
> extra check on identity that PyObjecct_RichCompare does not perform.

To me, the existence of two functions suggests that they are *intended* 
to act differently.
> 
> Here's the excerpt from RichCompareBool (line 612):
> 
> 	/* 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);
> 
> The code for PyObject_RichCompare does not contain this, it doesn't
> seem.  Is it a bug?
> --
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list