diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-13 19:23:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 19:23:48 (GMT) |
commit | 9b6c60cbce4ac45e8ccd7934babff465e9769509 (patch) | |
tree | 973d37d42dfe1ce66303ad0cf658bb20870aa88e /Objects/floatobject.c | |
parent | ce12629c84400c52734859e43b2386deb2b6da12 (diff) | |
download | cpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.zip cpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.tar.gz cpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.tar.bz2 |
bpo-31979: Simplify transforming decimals to ASCII (#4336)
in int(), float() and complex() parsers.
This also speeds up parsing non-ASCII numbers by around 20%.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 8d7a55a..47a174c 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -176,11 +176,10 @@ PyFloat_FromString(PyObject *v) s_buffer = _PyUnicode_TransformDecimalAndSpaceToASCII(v); if (s_buffer == NULL) return NULL; + assert(PyUnicode_IS_ASCII(s_buffer)); + /* Simply get a pointer to existing ASCII characters. */ s = PyUnicode_AsUTF8AndSize(s_buffer, &len); - if (s == NULL) { - Py_DECREF(s_buffer); - return NULL; - } + assert(s != NULL); } else if (PyBytes_Check(v)) { s = PyBytes_AS_STRING(v); |