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

Steven D'Aprano steve at pearwood.info
Tue Nov 21 19:45:06 EST 2017

On Tue, Nov 21, 2017 at 04:56:27PM -0600, Nick Timkovich wrote:
> On Tue, Nov 21, 2017 at 4:16 PM, Sven R. Kunze <srkunze at mail.de> wrote:
> > Maybe, that suffices: https://pypi.python.org/pypi/xheap
> >
> I still think the heapq.heap* functions are atrocious and they should
> immediately be packaged with *no additional features* into a stdlib object
> for reasons along the line of
> https://mail.python.org/pipermail/python-ideas/2017-October/047514.html

I think you pasted the wrong URL. That link is about pip, and the 
discoverability of third-party libraries. It says nothing about why 
functions are "atrocious" and why wrapping them into an object is 

But generally, Python's APIs are not "pure object oriented" in the Java 
sense, and we don't needlessly create objects just for the sake of 
ensuring everything is an object. Functions are fine too, and if the 
only difference between a function and method is the syntax you use to 
call it:

    function(value, arguments)



then that's a difference that makes no difference, and there is no 
advantage to using an object wrapper.

See also:


for a perspective on how the emphasis on objects is harmful.

What advantage is there to making the heap functions into Heap methods?


More information about the Python-ideas mailing list