From 6248f441ea3ca34ed3306eb8634e6815a42611b4 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 24 Aug 2002 06:31:34 +0000 Subject: [PATCH] Speedup for PyObject_IsTrue(): check for True and False first. Because all built-in tests return bools now, this is the most common path! --- Objects/object.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/object.c b/Objects/object.c index 1283294a06..523a8818ec 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1497,6 +1497,10 @@ int PyObject_IsTrue(PyObject *v) { int res; + if (v == Py_True) + return 1; + if (v == Py_False) + return 0; if (v == Py_None) return 0; else if (v->ob_type->tp_as_number != NULL && -- 2.40.0