-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
voteThe WG is voting (or has voted)The WG is voting (or has voted)
Description
Hi,
I propose adding the following function the Python 3.15 C API.
API: int PyUnicodeWriter_WriteASCII(PyUnicodeWriter *writer, const char *str, Py_ssize_t size)
Documentation:
Write the ASCII string str into writer.
size is the string length in bytes. If size is equal to
-1, callstrlen(str)to get the string length.str must only contain ASCII characters. The behavior is undefined if str contains non-ASCII characters.
On success, return
0.
On error, set an exception, leave the writer unchanged, and return-1.
The function is up to 2.0x faster than PyUnicodeWriter_WriteUTF8().
There are 2 reasons to add this function:
- Get the same performance when updating code using the old private
_PyUnicodeWriterAPI to use the new publicPyUnicodeWriterAPI. - Get the best performance for new code using the public
PyUnicodeWriterAPI: make the API appealing in term of performance.
Background: Using the public PyUnicodeWriter C API made the json module slower.
Vote:
Metadata
Metadata
Assignees
Labels
voteThe WG is voting (or has voted)The WG is voting (or has voted)