[Python-Dev] Rich Comparison from "C" API?
David Abrahams" <email@example.com
Wed, 12 Jun 2002 11:48:27 -0400
From: "Tim Peters" <firstname.lastname@example.org>
> 1. You really want PyObject_RichCompareBool in your example, not
> PyObject_RichCompare. The former is much more efficient in some
> cases (e.g., a total ordering on dicts is much hairer to determine
> than just equality).
Now you're really pulling my leg. PyObject_RichCompareBool is just:
/* Return -1 if error; 1 if v op w; 0 if not (v op w). */
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
PyObject *res = PyObject_RichCompare(v, w, op);
if (res == NULL)
ok = PyObject_IsTrue(res);
How can that be more efficient that PyObject_RichCompare?