mirror of
https://github.com/python/cpython.git
synced 2025-08-24 02:35:59 +00:00
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%.
This commit is contained in:
parent
ce12629c84
commit
9b6c60cbce
7 changed files with 63 additions and 139 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue