Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.09; 'received :mail-lpp01m010-f46.google.com': 0.09; 'sep': 0.09; 'skip:k 40': 0.09; 'subject:string': 0.09; '3.2.': 0.16; '3.3,': 0.16; '6:00': 0.16; 'instead:': 0.16; 'rewriting': 0.16; 'subject:unicode': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'example': 0.23; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'guess': 0.27; 'message- id:@mail.gmail.com': 0.27; 'actual': 0.28; '20%': 0.29; "i'm": 0.29; 'received:209.85.215.46': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'optimization': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'subject:...': 0.63; 'here': 0.65; 'otten': 0.84; 'subject:, ...': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Cnq9oFg3WvT1CkP63OVsc5gFkNkf49wA5Hhy6yJWrIU=; b=JHaFmeGoInsQrOcL13vnYoYghizcRDpHtJRXB+GLqvG7O8EdikPKUmu/lc4Q4bQKnI TdK4aM8Zhx6Mf/W72SdpRl1oeGa21mTdy53uZepYshe+7EZ2yfRmmyJ3I6ANMe0duNXn OUpy5VeAxVVWB5Pg3PjqiHZ4DX8pwFsDtHJAIx6oznnqNRCeZ7qHyBrjg/xXzj6nee/m UffrFXlGo/PHp6wi0TPWa9mNO52Jql0ZMHUfbaVbbsgUzPPqPD2OL53AJqOSlBfDjkVV HgCQaTcCWACVHOj6eFcBYdjB62E7GTYV9DaR2EHeVW4x0JSOrlGaaM9RpggDrkYCfIA/ FaKA== MIME-Version: 1.0 In-Reply-To: References: <503a0d51$0$6574$c3e8da3$5496439d@news.astraweb.com> <503a8361$0$6574$c3e8da3$5496439d@news.astraweb.com> <2e92da71-fbd2-467f-9088-1c79fa7bcf69@googlegroups.com> <62566024-df1d-4948-a27a-45c7820ddc6c@googlegroups.com> <503f0e45$0$9416$c3e8da3$76491128@news.astraweb.com> <2a12ba52-232a-41b7-a906-1ec379bbddd7@googlegroups.com> From: Ian Kelly Date: Mon, 3 Sep 2012 12:33:29 -0600 Subject: Re: Flexible string representation, unicode, typography, ... To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346697242 news.xs4all.nl 6876 [2001:888:2000:d::a6]:56655 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28364 On Sun, Sep 2, 2012 at 6:00 AM, Serhiy Storchaka 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.