Oh look, another language (ceylon)

Piet van Oostrum piet at vanoostrum.org
Mon Nov 18 09:31:45 EST 2013


Chris Angelico <rosuav at gmail.com> writes:

> On Mon, Nov 18, 2013 at 11:29 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
>>
>> On Nov 18, 2013 3:06 AM, "Chris Angelico" <rosuav at gmail.com> wrote:
>>>
>>> I'm trying to figure this out. Reading the docs hasn't answered this.
>>> If each character in a string is a 32-bit Unicode character, and (as
>>> can be seen in the examples) string indexing and slicing are
>>> supported, then does string indexing mean counting from the beginning
>>> to see if there were any surrogate pairs?
>>
>> The string reference says:
>>
>> """Since a String has an underlying UTF-16 encoding, certain operations are
>> expensive, requiring iteration of the characters of the string. In
>> particular, size requires iteration of the whole string, and get(), span(),
>> and segment() require iteration from the beginning of the string to the
>> given index."""
>>
>> The get and span operations appear to be equivalent to indexing and slicing.
>
> Right, that's what I was looking for and didn't find. (I was searching
> the one-page reference manual rather than reading in detail.) So, yes,
> they're O(n) operations. Thanks for hunting that down.
>
> ChrisA

It would be so much better to use the Flexible String Representation.
-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list