
I myself have proposed heap objects and seen that and other features come up from time to time. I think the general mood is to use a PyPI library, or even just vendor a single file from a package like xheap https://github.com/srkunze/xheap/blob/master/xheap.py If you wanted to stick with what's in the stdlib and have a minimal wrapper, you could turn your heap inputs into tuples of form `(key_function(object), object)`, and on getting them out, just get the object back. To have a max heap, key_function could just be operator.neg. On Wed, Apr 13, 2022 at 6:25 PM Eduardo Nery <eduardo.nery8@gmail.com> wrote:
Many times when using the heapq lib I had to convert my array to negative values so that it could behave like a max heap. Maybe we should pass in a parameter in the functions to specify if we want a max heap behaviour or a min heap behaviour. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/S5EF5V... Code of Conduct: http://python.org/psf/codeofconduct/