Commit f15d0b3c authored by Stefan Behnel's avatar Stefan Behnel

undo CheckExact broadening for RHS of optimised arithmetic expressions as...

undo CheckExact broadening for RHS of optimised arithmetic expressions as Python would still evaluate it to get the right subtype as result
parent 7fc33f75
...@@ -443,11 +443,11 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject ...@@ -443,11 +443,11 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t shiftby; Py_ssize_t shiftby;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(exp))) { if (likely(PyInt_CheckExact(exp))) {
shiftby = PyInt_AS_LONG(exp); shiftby = PyInt_AS_LONG(exp);
} else } else
#endif #endif
if (likely(PyLong_Check(exp))) { if (likely(PyLong_CheckExact(exp))) {
#if CYTHON_USE_PYLONG_INTERNALS #if CYTHON_USE_PYLONG_INTERNALS
const Py_ssize_t size = Py_SIZE(exp); const Py_ssize_t size = Py_SIZE(exp);
// tuned to optimise branch prediction // tuned to optimise branch prediction
...@@ -521,7 +521,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO ...@@ -521,7 +521,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
{{endif}} {{endif}}
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}}))) { if (likely(PyInt_CheckExact({{pyval}}))) {
const long {{'a' if order == 'CObj' else 'b'}} = intval; const long {{'a' if order == 'CObj' else 'b'}} = intval;
{{if c_op in '+-%' or op == 'FloorDivide'}} {{if c_op in '+-%' or op == 'FloorDivide'}}
long x; long x;
...@@ -573,7 +573,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO ...@@ -573,7 +573,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
#endif #endif
#if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
if (likely(PyLong_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}}))) { if (likely(PyLong_CheckExact({{pyval}}))) {
const long {{'a' if order == 'CObj' else 'b'}} = intval; const long {{'a' if order == 'CObj' else 'b'}} = intval;
long {{ival}}{{if op not in ('Eq', 'Ne')}}, x{{endif}}; long {{ival}}{{if op not in ('Eq', 'Ne')}}, x{{endif}};
{{if op not in ('Eq', 'Ne', 'TrueDivide')}} {{if op not in ('Eq', 'Ne', 'TrueDivide')}}
...@@ -672,7 +672,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO ...@@ -672,7 +672,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
#endif #endif
{{if c_op in '+-' or op in ('TrueDivide', 'Eq', 'Ne')}} {{if c_op in '+-' or op in ('TrueDivide', 'Eq', 'Ne')}}
if (PyFloat_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}})) { if (PyFloat_CheckExact({{pyval}})) {
const long {{'a' if order == 'CObj' else 'b'}} = intval; const long {{'a' if order == 'CObj' else 'b'}} = intval;
double {{ival}} = PyFloat_AS_DOUBLE({{pyval}}); double {{ival}} = PyFloat_AS_DOUBLE({{pyval}});
{{if op in ('Eq', 'Ne')}} {{if op in ('Eq', 'Ne')}}
...@@ -735,17 +735,17 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou ...@@ -735,17 +735,17 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
} }
{{endif}} {{endif}}
if (likely(PyFloat_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}}))) { if (likely(PyFloat_CheckExact({{pyval}}))) {
{{fval}} = PyFloat_AS_DOUBLE({{pyval}}); {{fval}} = PyFloat_AS_DOUBLE({{pyval}});
} else } else
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}}))) { if (likely(PyInt_CheckExact({{pyval}}))) {
{{fval}} = (double) PyInt_AS_LONG({{pyval}}); {{fval}} = (double) PyInt_AS_LONG({{pyval}});
} else } else
#endif #endif
if (likely(PyLong_Check{{ 'Exact' if order == 'ObjC' else ''}}({{pyval}}))) { if (likely(PyLong_CheckExact({{pyval}}))) {
#if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
const digit* digits = ((PyLongObject*){{pyval}})->ob_digit; const digit* digits = ((PyLongObject*){{pyval}})->ob_digit;
const Py_ssize_t size = Py_SIZE({{pyval}}); const Py_ssize_t size = Py_SIZE({{pyval}});
......
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