Flexible string representation, unicode, typography, ...
Terry Reedy
tjreedy at udel.edu
Sun Sep 2 16:38:34 EDT 2012
On 9/2/2012 3:45 PM, Michael Torrie wrote:
> In the worst case, Python's strings are as slow as Go because Python
> does the exact same thing as Go, but chooses between three encodings
> instead of just one. Best case scenario, Python's strings could be much
> faster than Go's because indexing through 2 of the 3 encodings is O(1)
In CPython 3.3, indexing of str text string objects is always O(1) and
it is always indexes and counts code points rather than code units. It
was the latter for narrow builds in 3.2 and before. As a result, single
character (code point) strings had a length of 2 rather than 1 for
extended plane characters. 3.3 corrects this.
--
Terry Jan Reedy
More information about the Python-list
mailing list