[Python-ideas] Adding a thin wrapper class around the functions in stdlib.heapq

Sven R. Kunze srkunze at mail.de
Wed Nov 22 05:16:56 EST 2017

On 22.11.2017 07:22, Nick Timkovich wrote:
> Functions are great. I'm a big fan of functions. However,
> 1. Once there are several that all have the same thing as an argument: 
> thing_operation1(thing, arg), thing_operation2(thing, arg)...it's 
> about time to bind them together.
> 2. And especially for the heap "soft-datatype": once it's heapified, 
> naively modifying it with other methods will ruin the heap invariant. 
> **The actual list you pass around can't be treated as a list.**

Two important aspects to which I want to add some thoughts.

The reason why I created xheap was because I actually needed a more 
complex datastructure which required more bookkeeping:

1) custom orders on the same data (list)
2) fast removal from within the heap

The plain "Heap" implementation (object wrapper of heapq) was just for 
the sake of completion.


PS: I tend to think that implementing xheap was easier BECAUSE the 
stdlib provided a function-only heap implementation. Nonetheless, both 
ways do have their merits.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171122/d8ae54be/attachment-0001.html>

More information about the Python-ideas mailing list