aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-11-13 21:23:48 +0200
committerGitHub <noreply@github.com>2017-11-13 21:23:48 +0200
commit9b6c60cbce4ac45e8ccd7934babff465e9769509 (patch)
tree973d37d42dfe1ce66303ad0cf658bb20870aa88e /Include/unicodeobject.h
parentbpo-28369: Enhance transport socket check in add_reader/writer (#4365) (diff)
downloadcpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.tar.gz
cpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.tar.bz2
cpython-9b6c60cbce4ac45e8ccd7934babff465e9769509.zip
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 'Include/unicodeobject.h')
-rw-r--r--Include/unicodeobject.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index d2a8ec281f1..61e713be072 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -1723,6 +1723,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeCodePage(
#endif /* MS_WINDOWS */
+#ifndef Py_LIMITED_API
/* --- Decimal Encoder ---------------------------------------------------- */
/* Takes a Unicode string holding a decimal value and writes it into
@@ -1747,14 +1748,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeCodePage(
*/
-#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Py_UNICODE *s, /* Unicode buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
char *output, /* Output buffer; must have size >= length */
const char *errors /* error handling */
) /* Py_DEPRECATED(3.3) */;
-#endif
/* Transforms code points that have decimal digit property to the
corresponding ASCII digit code points.
@@ -1762,19 +1761,18 @@ PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Returns a new Unicode string on success, NULL on failure.
*/
-#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
Py_UNICODE *s, /* Unicode buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to transform */
) /* Py_DEPRECATED(3.3) */;
-#endif
-/* Similar to PyUnicode_TransformDecimalToASCII(), but takes a PyObject
- as argument instead of a raw buffer and length. This function additionally
- transforms spaces to ASCII because this is what the callers in longobject,
- floatobject, and complexobject did anyways. */
+/* Coverts a Unicode object holding a decimal value to an ASCII string
+ for using in int, float and complex parsers.
+ Transforms code points that have decimal digit property to the
+ corresponding ASCII digit code points. Transforms spaces to ASCII.
+ Transforms code points starting from the first non-ASCII code point that
+ is neither a decimal digit nor a space to the end into '?'. */
-#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
PyObject *unicode /* Unicode object */
);