https://github.com/python/cpython/commit/8bf6305bc73917fb76c862c6d86f7343f46f4bfd
commit: 8bf6305bc73917fb76c862c6d86f7343f46f4bfd
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-10-10T20:09:32Z
summary:
gh-158451: Remove _PyUnicodeWriter_WriteASCIIString() read-only optim (#159141)
The optimization is not worth it, _PyUnicode_FromASCII() doesn't make
anything special.
files:
M Objects/unicode_writer.c
diff --git a/Objects/unicode_writer.c b/Objects/unicode_writer.c
index 6d921ed24de2984..e1c8cb884a102f1 100644
--- a/Objects/unicode_writer.c
+++ b/Objects/unicode_writer.c
@@ -401,18 +401,7 @@ _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
return 0;
}
- assert(ucs1lib_find_max_char((const Py_UCS1*)ascii, (const Py_UCS1*)ascii
+ len) < 128);
-
- if (writer->buffer == NULL && !writer->overallocate) {
- PyObject *str;
-
- str = _PyUnicode_FromASCII(ascii, len);
- if (str == NULL)
- return -1;
-
- _PyUnicodeWriter_SetReadOnly(writer, str, len);
- return 0;
- }
+ assert(ucs1lib_find_max_char((const Py_UCS1*)ascii, (const Py_UCS1*)ascii
+ len) <= 127);
if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) {
return -1;
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]