Flexible string representation, unicode, typography, ...

Ian Kelly ian.g.kelly at gmail.com
Mon Sep 3 14:33:29 EDT 2012


On Sun, Sep 2, 2012 at 6:00 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 02.09.12 12:52, Peter Otten wrote:
>>
>> Ian Kelly wrote:
>>
>>> Rewriting the example to use locale.strcoll instead:
>>
>>
>>>>>> sorted(li, key=functools.cmp_to_key(locale.strcoll))
>>
>>
>> There is also locale.strxfrm() which you can use directly:
>>
>> sorted(li, key=locale.strxfrm)
>
>
> Hmm, and with locale.strxfrm Python 3.3 20% slower than 3.2.

Doh!  In Python 3.3, strcoll and strxfrm are the same speed, so I
guess that the actual optimization I'm seeing here is that in Python
3.3, cmp_to_key(strcoll) has been optimized to return strxfrm.



More information about the Python-list mailing list