Best way to merge/sort two sorted lists?...

Neil Cerutti horpner at yahoo.com
Thu Dec 6 14:50:24 EST 2007


On 2007-12-06, Aaron Watters <aaron.watters at gmail.com> wrote:
> On Dec 6, 2:14 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>> On 2007-12-06, Raymond Hettinger <pyt... at rcn.com> wrote:
>> > See recipes:
>> >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491285
>> >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305269
>>
>> That's fairly awesome.
>
> The second one is!  That's why it works so fast.
> Tim Peters optimized this case!
> Gotta hand it to Tim Peters.  The first one should
> win some sort of obfuscated code contest, imho.
> It also seems to be 5 times slower than any of the others.
>
> btw: Neil's merge_sorted is a bit slower than any of mine due
> to the use of list.append, I think instead of preallocating a
> list of the right size.

I was hoping that, as it was slightly simpler that way, it would
be slightly faster. But sadly, it wasn't. I ultimately added that
optimization, too.

-- 
Neil Cerutti
I make love to pressure. --Stephen Jackson



More information about the Python-list mailing list