[Python-Dev] Replacement for array.array('u')?
storchaka at gmail.com
Fri Mar 22 07:31:48 EDT 2019
22.03.19 09:45, Victor Stinner пише:
> Internally, CPython has a _PyUnicodeWriter which is an efficient way
> to create a string but appending substrings or characters.
> _PyUnicodeWriter changes the internal storage format depending on
> characters code points (ascii or latin1: 1 byte/character, BMP: 2 b/c,
> full UCS: 4 b/c). I tried once to expose it in Python, but I wasn't
> convinced by performances. The overhead of method calls was quite
> significant, and I wasn't convinced by "writer += str" performance
> neither. Maybe I should try again. PyPy also has such object. It
> avoids the "str += str" hack in ceval.c to avoid very poor performance
> (_PyUnicodeWriter also uses overallocation which can be controlled
> with multiple parameters to reduce the number of realloc).
> Another alternative would be have to add a "strarray" type similar to
> bytes/bytearray couple.
Another alternative of mutable string buffer and string builder is
More information about the Python-Dev