"Lasse Vågsæther Karlsen" <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > George Sakkis <[EMAIL PROTECTED]> wrote: > <snip> > >>Yes, it's a little inconvenient that the builtin heap doesn't take a > >>comparison operation but you can easily roll your own heap by transforming > >>each item to a (key,item) tuple. Now that I'm thinking about it, it might > >>be a good addition to the cookbook. > > > > > > I believe Python 2.5 adds a key= argument to heapq's functions... > <snip> > > I will revisit the heapq solution when 2.5 is released then. > > Thanks for the heads up. For the moment I will stay with the list > solution that Mike came up with slightly changed to accomodate tips and > pointers from others in this thread.
Just added a recipe at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440673. You can try both and see if there's any significant performance difference for your data. George
-- http://mail.python.org/mailman/listinfo/python-list