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

Aaron Watters aaron.watters at gmail.com
Thu Dec 6 14:42:28 EST 2007


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.

 -- Aaron
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=inherently+hosed



More information about the Python-list mailing list