A note on heapq module

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Jan 18 11:57:56 CET 2007


Steven Bethard:
> Antoon Pardon:
> > For me, your class has the same drawback as the heappush, heappop
> > procedurers: no way to specify a comparision function.
>
> Agreed.  I'd love to see something like ``Heap(key=my_key_func)``.

It can be done, but the code becomes more complex and hairy:
http://rafb.net/p/iCCmDz16.html

(If someone spots a problem please tell me, thank you.)

Bye,
bearophile




More information about the Python-list mailing list