This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: heaps library does not have support for max heap
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: James.Lu, rhettinger, stutzbach
Priority: normal Keywords:

Created on 2016-06-11 13:49 by James.Lu, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg268211 - (view) Author: James Lu (James.Lu) * Date: 2016-06-11 13:49
Both max heaps and min heaps have uses in algorithms. Some algorithms require both. Why doesn't the heapq library support max heaps (not including the private _heapify_max() method)?
msg268269 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-06-11 20:39
Sorry James, we don't grow the APIs without sufficient demonstrated need; otherwise, we end-up with API sprawl.  People with actual use cases haven't requested behavior (and the occasional one-off gets by negating the numeric argument).  That is why the maxheap functions were intentionally made private.

FWIW, this module is very old and the core functions have long proven themselves sufficient to meet their use cases (like being used in an event loop to efficiently select the next scheduled event).
msg268370 - (view) Author: James Lu (James.Lu) * Date: 2016-06-12 12:36
It's not  a very pythoniic way to simply negate the value. Plus, the
majority of heap users want performance (heap was made for speed), so a C
version would be much better.

On Sat, Jun 11, 2016 at 4:39 PM, Raymond Hettinger <report@bugs.python.org>
wrote:

>
> Raymond Hettinger added the comment:
>
> Sorry James, we don't grow the APIs without sufficient demonstrated need;
> otherwise, we end-up with API sprawl.  People with actual use cases haven't
> requested behavior (and the occasional one-off gets by negating the numeric
> argument).  That is why the maxheap functions were intentionally made
> private.
>
> FWIW, this module is very old and the core functions have long proven
> themselves sufficient to meet their use cases (like being used in an event
> loop to efficiently select the next scheduled event).
>
> ----------
> resolution:  -> rejected
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue27295>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71482
2016-06-12 12:36:14James.Lusetmessages: + msg268370
2016-06-11 20:39:10rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg268269
2016-06-11 13:51:35SilentGhostsetnosy: + rhettinger, stutzbach

type: enhancement
versions: + Python 3.6
2016-06-11 13:49:52James.Lucreate