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 <[email protected]> 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 -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/S5EF5VZKNGJCYA7NQM5ESUZJC4DXXDV4/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/PL7AJ4NRBQ3PXCNQPDBCC276QJMB3N7D/ Code of Conduct: http://python.org/psf/codeofconduct/
