How do I display unicode value stored in a string variable using ord()
Chris Angelico
rosuav at gmail.com
Sat Aug 18 22:19:00 EDT 2012
On Sun, Aug 19, 2012 at 12:11 PM, Paul Rubin <no.email at nospam.invalid> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>> UTF-8 is highly inefficient for indexing. Given a buffer of (say) a
>> few thousand bytes, how do you locate the 273rd character?
>
> How often do you need to do that, as opposed to traversing the string by
> iteration? Anyway, you could use a rope-like implementation, or an
> index structure over the string.
Well, imagine if Python strings were stored in UTF-8. How would you slice it?
>>> "asdfqwer"[4:]
'qwer'
That's a not uncommon operation when parsing strings or manipulating
data. You'd need to completely rework your algorithms to maintain a
position somewhere.
ChrisA
More information about the Python-list
mailing list