mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Issue #25318: Add _PyBytesWriter API
Add a new private API to optimize Unicode encoders. It uses a small buffer allocated on the stack and supports overallocation. Use _PyBytesWriter API for UCS1 (ASCII and Latin1) and UTF-8 encoders. Enable overallocation for the UTF-8 encoder with error handlers. unicode_encode_ucs1(): initialize collend to collstart+1 to not check the current character twice, we already know that it is not ASCII.
This commit is contained in:
parent
08ec6d9611
commit
fdfbf78114
3 changed files with 269 additions and 133 deletions
|
@ -908,7 +908,7 @@ typedef struct {
|
|||
/* minimum character (default: 127, ASCII) */
|
||||
Py_UCS4 min_char;
|
||||
|
||||
/* If non-zero, overallocate the buffer by 25% (default: 0). */
|
||||
/* If non-zero, overallocate the buffer (default: 0). */
|
||||
unsigned char overallocate;
|
||||
|
||||
/* If readonly is 1, buffer is a shared string (cannot be modified)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue