Commit b8305e4a authored by Stefan Behnel's avatar Stefan Behnel

Copy also the short long_neg() code from CPython for the specialised...

Copy also the short long_neg() code from CPython for the specialised "abs(PyLong)" implementation to avoid jumping through call pointer indirections.
parent 2fa0e9f6
...@@ -275,7 +275,17 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) { ...@@ -275,7 +275,17 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
// digits are unsigned // digits are unsigned
return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]); return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]);
} }
return ((PyTypeObject*)Py_TYPE(n))->tp_as_number->nb_negative(n); #if CYTHON_COMPILING_IN_CPYTHON
{
PyObject *copy = _PyLong_Copy((PyLongObject*)n);
if (likely(copy)) {
Py_SIZE(copy) = -(Py_SIZE(copy));
}
return copy;
}
#else
return PyNumber_Negative(n);
#endif
} }
#endif #endif
......
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