Commit 0bc3d7b7 authored by Robert Bradshaw's avatar Robert Bradshaw

Another object -> bint optimization.

__Pyx_PyObject_IsTrue now has only a single branch, even at -O0.
(The bitwise | is intentional.) This is only a 2.5% or so speedup
in my microbenchmarks, but it's something.
parent 7e10fc77
......@@ -2485,12 +2485,13 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
""" + type_conversion_predeclarations
# Note: __Pyx_PyObject_IsTrue is written to minimize branching.
type_conversion_functions = """
/* Type Conversion Functions */
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
if (x == Py_True) return 1;
else if ((x == Py_False) || (x == Py_None)) return 0;
int is_true = x == Py_True;
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
else return PyObject_IsTrue(x);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment