<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 21, 2017 at 6:45 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Nov 21, 2017 at 04:56:27PM -0600, Nick Timkovich wrote:<br>
> On Tue, Nov 21, 2017 at 4:16 PM, Sven R. Kunze <<a href="mailto:srkunze@mail.de">srkunze@mail.de</a>> wrote:<br>
><br>
> > Maybe, that suffices: <a href="https://pypi.python.org/pypi/xheap" rel="noreferrer" target="_blank">https://pypi.python.org/pypi/<wbr>xheap</a><br>
> ><br>
> I still think the heapq.heap* functions are atrocious and they should<br>
> immediately be packaged with *no additional features* into a stdlib object<br>
> for reasons along the line of<br>
> <a href="https://mail.python.org/pipermail/python-ideas/2017-October/047514.html" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>pipermail/python-ideas/2017-<wbr>October/047514.html</a><br>
<br>
</span>I think you pasted the wrong URL. That link is about pip, and the<br>
discoverability of third-party libraries. <br></blockquote><div><br></div><div>Probably straining the reference, but akin to "don't teach JSON with Python, teach XML-RPC because it supports that better in the stdlib", why not "don't teach heaps, just use lists with pop and insert+sort".</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But generally, Python's APIs are not "pure object oriented" in the Java<br>
sense, and we don't needlessly create objects just for the sake of<br>
ensuring everything is an object. Functions are fine too...</blockquote><div><br></div><div>Functions are great. I'm a big fan of functions. However,</div><div><br></div><div>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.</div><div>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.**</div></div><br></div></div>