[Python-Dev] Internal representation of strings and Micropython

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jun 5 02:57:16 CEST 2014


Glenn Linderman wrote:
> 
> so algorithms that walk two strings at a time cannot use the same 
> StringPosition to do so... yep, this is quite divergent from CPython and 
> Python.

They can, it's just that at most one of the indexing
operations would be fast; the StringPosition would
devolve into an int for the other one.

Such an algorithm would be of dubious correctness
anyway, since as you pointed out, codepoints and
characters are not quite the same thing. A codepoint
index in one string doesn't necessarily count off
the same number of characters in another string.
So to be safe, you should really walk each string
individually.

-- 
Greg


More information about the Python-Dev mailing list