Commit 09f6874a authored by Stefan Behnel's avatar Stefan Behnel

speed up Python long integer operations in Python 2.7

This it less important than in Py3 as most optimisable cases are already covered by PyInt, but long objects might still pop up arbitrarily in Py2, so it might be worth it.
parent 569f1662
......@@ -36,6 +36,8 @@ Features added
* Binary lshift operations with small constant Python integers are faster.
* Some integer operations on Python long objects are faster in Python 2.7.
Bugs fixed
----------
......
......@@ -604,7 +604,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
}
#endif
#if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
if (likely(PyLong_CheckExact({{pyval}}))) {
const long {{'a' if order == 'CObj' else 'b'}} = intval;
long {{ival}}{{if op not in ('Eq', 'Ne')}}, x{{endif}};
......@@ -787,7 +787,7 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
#endif
if (likely(PyLong_CheckExact({{pyval}}))) {
#if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*){{pyval}})->ob_digit;
const Py_ssize_t size = Py_SIZE({{pyval}});
switch (size) {
......
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