diff options
author | Victor Stinner <vstinner@python.org> | 2024-05-22 21:05:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-22 21:05:26 (GMT) |
commit | 9b422fc6af87b81812aaf3010c004eb27c4dc280 (patch) | |
tree | 306e72e7ff377b61477790ac8c9efd38b5f3445b /Python/tracemalloc.c | |
parent | 14b063cbf1bb11a489d04a31f277edba0fc8893c (diff) | |
download | cpython-9b422fc6af87b81812aaf3010c004eb27c4dc280.zip cpython-9b422fc6af87b81812aaf3010c004eb27c4dc280.tar.gz cpython-9b422fc6af87b81812aaf3010c004eb27c4dc280.tar.bz2 |
gh-119396: Optimize PyUnicode_FromFormat() UTF-8 decoder (#119398)
Add unicode_decode_utf8_writer() to write directly characters into a
_PyUnicodeWriter writer: avoid the creation of a temporary string.
Optimize PyUnicode_FromFormat() by using the new
unicode_decode_utf8_writer().
Rename unicode_fromformat_write_cstr() to
unicode_fromformat_write_utf8().
Microbenchmark on the code:
return PyUnicode_FromFormat(
"%s %s %s %s %s.",
"format", "multiple", "utf8", "short", "strings");
Result: 620 ns +- 8 ns -> 382 ns +- 2 ns: 1.62x faster.
Diffstat (limited to 'Python/tracemalloc.c')
0 files changed, 0 insertions, 0 deletions