On Fri, Feb 1, 2019 at 2:00 PM MRAB <pyt...@mrabarnett.plus.com> wrote: > > On 2019-02-01 00:28, Avi Gross wrote: > > The second variant is to use the newer bytearray data structure very > > carefully as it is to a first approximation a mutable string. Adding to the > > end of a new one should be quick. WARNING: I said be careful. A bytearray is > > more like a list of 8-bit ints. With care you can handle ASCII text. > > > If you're replacing anything within the ASCII range, it'll also work for > UTF-8!
It'll work if you represent the string as UTF-8 bytes, yes. Perhaps it would be better to represent a string as a sequence of 21-bit integers instead of 8-bit integers? ChrisA -- https://mail.python.org/mailman/listinfo/python-list