summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-24 05:33:28 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-24 05:33:28 (GMT)
commit81912d4764eb8ccb1b069de46c7f78381f4b19a6 (patch)
treedc3ca526440c32fea11b229f07cc4c3b4a8dc524 /Objects/object.c
parentd50185127f5cdc7241e5aa80d4d174113bf43b52 (diff)
downloadcpython-81912d4764eb8ccb1b069de46c7f78381f4b19a6.zip
cpython-81912d4764eb8ccb1b069de46c7f78381f4b19a6.tar.gz
cpython-81912d4764eb8ccb1b069de46c7f78381f4b19a6.tar.bz2
Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
always returns a bool, so avoid calling PyObject_IsTrue() in that case.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 04a7c1f..1283294 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -998,7 +998,10 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
if (res == NULL)
return -1;
- ok = PyObject_IsTrue(res);
+ if (PyBool_Check(res))
+ ok = (res == Py_True);
+ else
+ ok = PyObject_IsTrue(res);
Py_DECREF(res);
return ok;
}