Bringing Order to programming

Chris Angelico rosuav at gmail.com
Thu Jan 31 22:08:39 EST 2019


On Fri, Feb 1, 2019 at 2:00 PM MRAB <python at 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



More information about the Python-list mailing list