Support max heaps in heapq module

Hi, I understand that the default implementation of heapq.heapify is to create a min-heap. The logic for max-heapify has already been implemented inside _heapify_max and along with that for corresponding push and pop operations. But they are not exposed to the user and hence not mentioned in any of the docs. I am unable to find any explanation as to why this is so. Current methods of implementing max-heaps (according to the SO question mentioned below) involves inverting the signs of numeric values and other workarounds. Therefore, I would like to propose officially supporting max-heaps as a part of heapq module. SO Q&A regarding the issue : https://stackoverflow.com/questions/2501457/what-do-i-use-for-a-max-heap-imp... Thank you -- Abhai Kollara

It is easy to have a wrapper class around the heapq functions so that you can use an arbitrary comparison on the heap. I have an answer with such an snippet, that got some activity today - maybe exactly due to your questioning: https://stackoverflow.com/questions/8875706/heapq-with-custom-compare-predic... On Fri, 20 Mar 2020 at 14:30, Abhai Kollara <abhai.dilip@gmail.com> wrote:

It is easy to have a wrapper class around the heapq functions so that you can use an arbitrary comparison on the heap. I have an answer with such an snippet, that got some activity today - maybe exactly due to your questioning: https://stackoverflow.com/questions/8875706/heapq-with-custom-compare-predic... On Fri, 20 Mar 2020 at 14:30, Abhai Kollara <abhai.dilip@gmail.com> wrote:
participants (2)
-
Abhai Kollara
-
Joao S. O. Bueno