Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6248f44

Browse files
committed
Speedup for PyObject_IsTrue(): check for True and False first.
Because all built-in tests return bools now, this is the most common path!
1 parent 1b9f5d4 commit 6248f44

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/object.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,10 @@ int
14971497
PyObject_IsTrue(PyObject *v)
14981498
{
14991499
int res;
1500+
if (v == Py_True)
1501+
return 1;
1502+
if (v == Py_False)
1503+
return 0;
15001504
if (v == Py_None)
15011505
return 0;
15021506
else if (v->ob_type->tp_as_number != NULL &&

0 commit comments

Comments
 (0)