Commit 31375964 authored by Stefan Behnel's avatar Stefan Behnel

fix (and simplify) object->double conversion in PyPy

parent 87b56a4b
...@@ -442,14 +442,22 @@ static CYTHON_INLINE int __Pyx_init_unicode_iteration( ...@@ -442,14 +442,22 @@ static CYTHON_INLINE int __Pyx_init_unicode_iteration(
/////////////// pyobject_as_double.proto /////////////// /////////////// pyobject_as_double.proto ///////////////
#if CYTHON_COMPILING_IN_PYPY
// currently works because PyPy calls float() internally
#define __Pyx_PyObject_AsDouble(obj) PyFloat_AsDouble(obj)
#else
static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */ static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#define __Pyx_PyObject_AsDouble(obj) \ #define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \ ((likely(PyFloat_CheckExact(obj))) ? \
PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif
/////////////// pyobject_as_double /////////////// /////////////// pyobject_as_double ///////////////
#if !CYTHON_COMPILING_IN_PYPY
static double __Pyx__PyObject_AsDouble(PyObject* obj) { static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyObject* float_value; PyObject* float_value;
if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) { if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
...@@ -476,3 +484,4 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) { ...@@ -476,3 +484,4 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
bad: bad:
return (double)-1; return (double)-1;
} }
#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