Commit 320fa6d7 authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Merge pull request #3962 from da-woods/string_to_float

Always use "new" string->float conversions
parents e6f92c17 0a3cc077
...@@ -2195,6 +2195,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin, ...@@ -2195,6 +2195,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
args=[func_arg], args=[func_arg],
py_name='float', py_name='float',
is_temp=node.is_temp, is_temp=node.is_temp,
utility_code = UtilityCode.load_cached("pynumber_float", "TypeConversion.c"),
result_is_used=node.result_is_used, result_is_used=node.result_is_used,
).coerce_to(node.type, self.current_env()) ).coerce_to(node.type, self.current_env())
return node return node
......
...@@ -713,7 +713,6 @@ static double __Pyx_SlowPyString_AsDouble(PyObject *obj) { ...@@ -713,7 +713,6 @@ static double __Pyx_SlowPyString_AsDouble(PyObject *obj) {
static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) { static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) {
Py_ssize_t i; Py_ssize_t i;
char *digit = buffer;
for (i=0; i < length; i++) { for (i=0; i < length; i++) {
if (start[i] != '_') *buffer++ = start[i]; if (start[i] != '_') *buffer++ = start[i];
} }
......
...@@ -126,7 +126,8 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); ...@@ -126,7 +126,8 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#else #else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif #endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) // __Pyx_PyNumber_Float is now in it's own section since it has dependencies (needed to make
// string conversion work the same in all circumstances)
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_sys_getdefaultencoding_not_ascii;
...@@ -463,6 +464,27 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { ...@@ -463,6 +464,27 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return PyInt_FromSize_t(ival); return PyInt_FromSize_t(ival);
} }
/////////////// pynumber_float.proto ///////////////
static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj); /* proto */
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : __Pyx__PyNumber_Float(x))
/////////////// pynumber_float ///////////////
//@requires: Optimize.c::pybytes_as_double
//@requires: Optimize.c::pyunicode_as_double
static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj) {
// obj is PyFloat is handled in the calling macro
if (PyUnicode_CheckExact(obj)) {
return PyFloat_FromDouble(__Pyx_PyUnicode_AsDouble(obj));
} else if (PyBytes_CheckExact(obj)) {
return PyFloat_FromDouble(__Pyx_PyBytes_AsDouble(obj));
} else if (PyByteArray_CheckExact(obj)) {
return PyFloat_FromDouble(__Pyx_PyByteArray_AsDouble(obj));
} else {
return PyNumber_Float(obj);
}
}
/////////////// GCCDiagnostics.proto /////////////// /////////////// GCCDiagnostics.proto ///////////////
......
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