[Python-ideas] Consider adding reverse argument to heapq methods.

Elias Zamaria mikez302 at gmail.com
Thu Mar 8 02:29:12 EST 2018


Or if we are willing to make bigger changes to the module, there should be 
a sort of class that can remember if it is supposed to represent a min-heap 
or a max-heap. This has been discussed several times:

   - https://groups.google.com/d/topic/python-ideas/h3WLmpBG4ug/discussion
   - https://groups.google.com/d/topic/python-ideas/WQMhF79oCzw/discussion
   - https://groups.google.com/d/topic/python-ideas/NmL53DLTqpo/discussion
   - https://groups.google.com/d/topic/python-ideas/cLIAhBbQ8xA/discussion
   
But nothing definite has come out of those discussions, as far as I can 
tell.

On Tuesday, March 6, 2018 at 9:59:00 AM UTC-8, Neil Girdhar wrote:
>
> heapq creates and works with min-heaps.  Currently, the only way to do 
> this is to use _heapify_max instead of heapify, heapq._heappop_max instead 
> of heapq.heappop, etc.
>
> These methods should be exposed using a reverse keyword argument rather 
> than as private methods just like sort.
>
> Best,
>
> Neil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180307/14da2206/attachment.html>


More information about the Python-ideas mailing list