]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Speedup for PyObject_IsTrue(): check for True and False first.
authorGuido van Rossum <guido@python.org>
Sat, 24 Aug 2002 06:31:34 +0000 (06:31 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 24 Aug 2002 06:31:34 +0000 (06:31 +0000)
Because all built-in tests return bools now, this is the most common
path!

Objects/object.c

index 1283294a060e5d817974afab19f66bf081e160b7..523a8818ec477affa0cb5a8ea61d4895d3cd69f7 100644 (file)
@@ -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 &&