diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2021-04-03 07:42:25 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2021-04-03 07:43:06 +0200 |
commit | f1d021fe76ee7d7e192044ef44969929a6ed7bc0 (patch) | |
tree | f5b4de91c658999302012c1155085ba2cbb79a61 | |
parent | 571514e61e0a88c16cc2a00251366087aee72692 (diff) | |
download | cython-f1d021fe76ee7d7e192044ef44969929a6ed7bc0.tar.gz |
Special case float parsing in PyPy since byte string access is likely slower there than a plain float object creation. (And it works in all PyPy versions.)
-rw-r--r-- | Cython/Utility/Optimize.c | 12 | ||||
-rw-r--r-- | tests/pypy_bugs.txt | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c index c20dea098..81c8b16a6 100644 --- a/Cython/Utility/Optimize.c +++ b/Cython/Utility/Optimize.c @@ -667,7 +667,7 @@ static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj);/*proto*/ static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) { // Currently not optimised for 1) Py2.7 and 2) Py3 unicode strings with non-ASCII whitespace. // See __Pyx__PyBytes_AsDouble() below, the same byte buffer copying could be done here. -#if PY_MAJOR_VERSION >= 3 +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY if (unlikely(PyUnicode_READY(obj) == -1)) return (double)-1; if (likely(PyUnicode_IS_ASCII(obj))) { @@ -687,10 +687,18 @@ static double __Pyx_SlowPyString_AsDouble(PyObject *obj);/*proto*/ static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length);/*proto*/ static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) { +#if CYTHON_COMPILING_IN_PYPY + return __Pyx_SlowPyString_AsDouble(obj); +#else return __Pyx__PyBytes_AsDouble(obj, PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj)); +#endif } static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) { +#if CYTHON_COMPILING_IN_PYPY + return __Pyx_SlowPyString_AsDouble(obj); +#else return __Pyx__PyBytes_AsDouble(obj, PyByteArray_AS_STRING(obj), PyByteArray_GET_SIZE(obj)); +#endif } @@ -720,7 +728,7 @@ static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, return buffer; } -static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) { +static CYTHON_UNUSED double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) { double value; Py_ssize_t i, digits; const char *last = start + length; diff --git a/tests/pypy_bugs.txt b/tests/pypy_bugs.txt index 7e97c1efb..2ed1eb970 100644 --- a/tests/pypy_bugs.txt +++ b/tests/pypy_bugs.txt @@ -2,10 +2,6 @@ # either in PyPy, PyPy's cpyext, or Cython under PyPy, # which will be skipped in the normal testing run. -# See https://foss.heptapod.net/pypy/pypy/-/issues/3375 -float_division -specialfloat - broken_exception bufaccess memoryview.memoryview$ |