[issue20905] Adapt heapq push/pop/replace to allow passing a comparator.

Prashant Sharma report at bugs.python.org
Thu Mar 13 10:45:48 CET 2014


Prashant Sharma added the comment:

Hey Gareth,

"add Key=" approach also solves the purpose. The purpose is to be able to use heapq as max heap too conveniently. (I just wish python had minmaxheap too, but felt that is too much to ask for.) It is a very common usage and usual tricks of inverting the values( or negating) isn't great for all purposes. 

I am happy to redo the patch, if that is an acceptable solution. 

On a side note, did we also discuss about making some public functions for using heapq as max heap. (There are a few internal functions for the same).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20905>
_______________________________________


More information about the Python-bugs-list mailing list