flaming vs accuracy [was Re: Performance of int/long in Python 3]
Terry Reedy
tjreedy at udel.edu
Thu Mar 28 12:01:25 EDT 2013
On 3/28/2013 10:38 AM, Chris Angelico wrote:
> PEP393 strings have two optimizations, or kinda three:
>
> 1a) ASCII-only strings
> 1b) Latin1-only strings
> 2) BMP-only strings
> 3) Everything else
>
> Options 1a and 1b are almost identical - I'm not sure what the detail
> is, but there's something flagging those strings that fit inside seven
> bits. (Something to do with optimizing encodings later?)
Yes. 'Encoding' an ascii-only string to any ascii-compatible encoding
amounts to a simple copy of the internal bytes. I do not know if *all*
the codecs for such encodings are 393-aware, but I do know that the
utf-8 and latin-1 group are. This is one operation that 3.3+ does much
faster than 3.2-
--
Terry Jan Reedy
More information about the Python-list
mailing list