Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35660

Re: Custom alphabetical sort

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 <ian.g.kelly@gmail.com>
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 <kbihen$lo7$1@ger.gmane.org>
References <40d108ec-b019-4829-a969-c8ef513866f1@googlegroups.com> <8fc90ea6-4787-4f98-b4b8-c3ae5418d5f0@googlegroups.com> <kbihen$lo7$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 27 Dec 2012 16:17:53 -0700
Subject Re: Custom alphabetical sort
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1375.1356650314.29569.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, Dec 27, 2012 at 3:17 PM, Terry Reedy <tjreedy@udel.edu> 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, and
> result.

There was another thread about this one a while back.  Using IDLE on Windows XP:

>>> import timeit, locale
>>> li = ['noël', 'noir', 'nœud', 'noduleux', 'noétique', 'noèse', 'noirâtre']
>>> locale.setlocale(locale.LC_ALL, 'French_France')
'French_France.1252'

>>> # Python 3.2
>>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from __main__ import li", number=100000))
1.1581226105552531

>>> # Python 3.3.0
>>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from __main__ import li", number=100000))
1.4595282361305697

1.460 / 1.158 = 1.261

>>> li = li * 100
>>> import random
>>> random.shuffle(li)

>>> # Python 3.2
>>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from __main__ import li", number=1000))
1.233450899485831

>>> # Python 3.3.0
>>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from __main__ import li", number=1000))
1.5793845307155152

1.579 / 1.233 = 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 07:32 -0800
  Re: Custom alphabetical sort Thomas Bach <thbach@students.uni-mainz.de> - 2012-12-24 17:11 +0100
    Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 08:34 -0800
      Re: Custom alphabetical sort Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-24 10:29 -0700
    Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 08:34 -0800
  Re: Custom alphabetical sort wxjmfauth@gmail.com - 2012-12-27 10:17 -0800
    Re: Custom alphabetical sort Terry Reedy <tjreedy@udel.edu> - 2012-12-27 17:17 -0500
    Re: Custom alphabetical sort Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-27 16:17 -0700
      Re: Custom alphabetical sort wxjmfauth@gmail.com - 2012-12-28 02:27 -0800

csiph-web