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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'argument': 0.04; 'ascii': 0.07; 'locale': 0.07; 'python': 0.09; 'terry': 0.09; 'thread': 0.11; 'dec': 0.15; 'result.': 0.15; '"import': 0.16; 'reedy': 0.16; 'sorting': 0.16; 'wrote:': 0.17; 'replacing': 0.17; 'thu,': 0.17; '>>>': 0.18; 'code,': 0.18; 'windows': 0.19; 'import': 0.21; '3.2': 0.22; 'back.': 0.22; 'os,': 0.22; 'random': 0.24; 'header :In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'actual': 0.28; 'build,': 0.29; 'words': 0.29; "skip:' 10": 0.30; 'system,': 0.32; "skip:' 20": 0.32; 'idle': 0.33; 'to:addr:python- list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'skip:k 20': 0.35; 'skip:l 30': 0.35; 'so,': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'list.': 0.35; 'but': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'short': 0.39; 'header:Received:5': 0.40; 'back': 0.62; 'skip:n 10': 0.63; 'more': 0.63; 'french': 0.64; 'charset:windows-1252': 0.65; '100': 0.78; 'comparable': 0.84; 'to:name:python': 0.84; '40%': 0.91 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:content-transfer-encoding; bh=N352k7U/fZrLLvzal5gDFJuSsyRellEFok1z36ouNws=; b=GPzQcYXVTlUh3/CJ8anZuixAFlqG49Hbg5PGe+lxFkXmeDAkHVDWdm6okaggsFEpL9 vEIqRJ620ijOjNKlgRgUwQsGICGyjNgu8+zVb+uS+ymM9qNUQqlMvrtWjdCxUep1fYUE KRAveWnl67go9ZB7OMoFAViFLjwCFYxMlfmo5OWIbnwSaJz0mFYxEKS+YAX8pF/pHh1u 7o49JWl7s4j/PTWDUDvIPY2tksUr04IscqJR4HLe4JFgWr6Vu56AhBs6kkny/h6qTzOw crcaPTcRJwBoZgk9wThNidHUADU+Q2sVAI2AEvigbtsUeoPMJr98nH3l1RrAKE0NusS7 d86w== MIME-Version: 1.0 In-Reply-To: References: <40d108ec-b019-4829-a969-c8ef513866f1@googlegroups.com> <8fc90ea6-4787-4f98-b4b8-c3ae5418d5f0@googlegroups.com> From: Ian Kelly Date: Thu, 27 Dec 2012 16:17:53 -0700 Subject: Re: Custom alphabetical sort To: Python Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356650314 news.xs4all.nl 6983 [2001:888:2000:d::a6]:58067 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35660 On Thu, Dec 27, 2012 at 3:17 PM, Terry Reedy wrote: >> PS Py 3.3 warranty: ~30% slower than Py 3.2 > > > Do you have any actual timing data to back up that claim? > If so, please give specifics, including build, os, system, timing code, a= nd > result. There was another thread about this one a while back. Using IDLE on Window= s XP: >>> import timeit, locale >>> li =3D ['no=EBl', 'noir', 'n=9Cud', 'noduleux', 'no=E9tique', 'no=E8se'= , 'noir=E2tre'] >>> locale.setlocale(locale.LC_ALL, 'French_France') 'French_France.1252' >>> # Python 3.2 >>> min(timeit.repeat("sorted(li, key=3Dlocale.strxfrm)", "import locale; f= rom __main__ import li", number=3D100000)) 1.1581226105552531 >>> # Python 3.3.0 >>> min(timeit.repeat("sorted(li, key=3Dlocale.strxfrm)", "import locale; f= rom __main__ import li", number=3D100000)) 1.4595282361305697 1.460 / 1.158 =3D 1.261 >>> li =3D li * 100 >>> import random >>> random.shuffle(li) >>> # Python 3.2 >>> min(timeit.repeat("sorted(li, key=3Dlocale.strxfrm)", "import locale; f= rom __main__ import li", number=3D1000)) 1.233450899485831 >>> # Python 3.3.0 >>> min(timeit.repeat("sorted(li, key=3Dlocale.strxfrm)", "import locale; f= rom __main__ import li", number=3D1000)) 1.5793845307155152 1.579 / 1.233 =3D 1.281 So about 26% slower for sorting a short list of French words and about 28% slower for a longer list. Replacing the strings with ASCII and removing the 'key' argument gives a comparable result for the long list but more like a 40% slowdown for the short list.