Why is array.array('u') deprecated?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri May 8 06:29:04 EDT 2015
On Fri, 8 May 2015 07:14 pm, jonathan.slenders at gmail.com wrote:
> Why is array.array('u') deprecated?
>
> Will we get an alternative for a character array or mutable unicode
> string?
Good question.
Of the three main encodings for Unicode, two are variable-width:
* UTF-8 uses 1-4 bytes per character
* UTF-16 uses 2 or 4 bytes per character
while UTF-32 is fixed-width (4 bytes per character). So you could try faking
it with a 32-bit array and filling it with string.encode('utf-32').
--
Steven
More information about the Python-list
mailing list