heapq "key" arguments
Joshua Bronson
jabronson at gmail.com
Fri Jul 31 15:38:01 EDT 2009
On Jul 31, 2:02 pm, Jonathan Gardner <jgard... at jonathangardner.net>
wrote:
> On Jul 31, 10:44 am, Joshua Bronson <jabron... at gmail.com> wrote:
>
> > Say I want to maintain a heap of (x, y) pairs sorted only by
> > first coordinate. Without being able to pass key=itemgetter(0), won't
> > heapifying a list of such pairs unnecessarily compare both
> > coordinates?
>
> It will compare the second value only if the first values are equal.
I don't see how that helps. That's not at all the same thing as being
able to pass key=itemgetter(0).
More information about the Python-list
mailing list