[Tutor] List comprehension question

Stefan Behnel stefan_ml at behnel.de
Fri Nov 12 07:23:11 CET 2010


Steven D'Aprano, 12.11.2010 06:07:
> Richard D. Moores wrote:
>> On Wed, Nov 10, 2010 at 01:30, Steven D'Aprano wrote:
>
>>> P.S. don't take that as a put down -- you should be pleased that your
>>> code is around as fast as Tim Peter's code :)
>>
>> Nah. But where is Tim Peter's code?
>
> The timeit module was written by Tim Peters. Since then, others have
> contributed as well, but the basic recipe is his.

The OP might have been referring to the stackoverflow comment that quotes 
the algorithm solving the OP's problem:

http://stackoverflow.com/questions/1024640/calculating-phik-for-1kn


> For those who don't know, Tim Peters, a.k.a. the timbot, is one of the
> old-time Python demigods. He is responsible for not one, but two,
> awesomely fast sort routines: the original list.sort() method was his,
> and then around Python 2.3 (I think) he re-wrote it using a new sort
> method which is even faster, added stability, and has fewer special
> cases than the previous version. This sort algorithm has since been
> adopted by Android and Java 7.

It's commonly referred to as "Timsort".

http://en.wikipedia.org/wiki/Timsort
http://bugs.python.org/file4451/timsort.txt
http://corte.si/posts/code/timsort/index.html

Stefan



More information about the Tutor mailing list