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

Streamline __Pyx_PyNumber_IntOrLong() with direct slot calls instead of C-API...

Streamline __Pyx_PyNumber_IntOrLong() with direct slot calls instead of C-API function calls that only do what we already do on our side already.
parent 6a99c289
...@@ -293,9 +293,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { ...@@ -293,9 +293,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
const char *name = NULL; const char *name = NULL;
PyObject *res = NULL; PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (PyInt_Check(x) || PyLong_Check(x)) if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else #else
if (PyLong_Check(x)) if (likely(PyLong_Check(x)))
#endif #endif
return __Pyx_NewRef(x); return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS #if CYTHON_USE_TYPE_SLOTS
...@@ -303,26 +303,26 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { ...@@ -303,26 +303,26 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (m && m->nb_int) { if (m && m->nb_int) {
name = "int"; name = "int";
res = PyNumber_Int(x); res = m->nb_int(x);
} }
else if (m && m->nb_long) { else if (m && m->nb_long) {
name = "long"; name = "long";
res = PyNumber_Long(x); res = m->nb_long(x);
} }
#else #else
if (m && m->nb_int) { if (likely(m && m->nb_int)) {
name = "int"; name = "int";
res = PyNumber_Long(x); res = m->nb_int(x);
} }
#endif #endif
#else #else
res = PyNumber_Int(x); res = PyNumber_Int(x);
#endif #endif
if (res) { if (likely(res)) {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (!PyInt_Check(res) && !PyLong_Check(res)) { if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else #else
if (!PyLong_Check(res)) { if (unlikely(!PyLong_Check(res))) {
#endif #endif
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)", "__%.4s__ returned non-%.4s (type %.200s)",
......
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