Commit 8bd40d68 authored by Stefan Behnel's avatar Stefan Behnel

change optimisation order as for N in (2**N) it is much more likely to be an int than a long in Py2

parent bad722a6
......@@ -442,6 +442,11 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
// see http://bugs.python.org/issue21420
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t shiftby;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(exp))) {
shiftby = PyInt_AS_LONG(exp);
} else
#endif
if (likely(PyLong_CheckExact(exp))) {
#if PY_MAJOR_VERSION >= 3 && CYTHON_USE_PYLONG_INTERNALS
switch (Py_SIZE(exp)) {
......@@ -454,10 +459,6 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
#else
shiftby = PyLong_AsSsize_t(exp);
#endif
#if PY_MAJOR_VERSION < 3
} else if (likely(PyInt_CheckExact(exp))) {
shiftby = PyInt_AS_LONG(exp);
#endif
} else {
goto fallback;
}
......
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