heapq "key" arguments

Jonathan Gardner jgardner at jonathangardner.net
Fri Jul 31 20:02:48 CEST 2009


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.



More information about the Python-list mailing list