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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 23 03:02:27 EST 2017


Grant Jenks wrote:
> The heap algorithm is exposed through a high-level 
> functional interface so that you can take advantage of duck-typing.

This would also be true of a HeapWrapper class that wrapped
an existing sequence.

There's a difference between the heap functions and sorted().
The latter is just a single function that does its job and
returns a result. But the heap interface is a collection of
functions that have to be used together in the right way
to maintain the heap invariants. That suggests some
encapsulation is in order.

-- 
Greg


More information about the Python-ideas mailing list