Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35660
| 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 | 2012-12-27 16:17 -0700 |
| Subject | Re: Custom alphabetical sort |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1375.1356650314.29569.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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