<div dir="ltr"><div><div><div><div>I thought the purpose of heapq was to have a ready-made example<br></div>for instructors on how an API can be improved by applying object-oriented techniques. ;-)<br><br></div>I think adding a HeapQueue class would be a great idea. Obviously the existing functions<br></div>would need to continue existing for backward compatibility.<br><br></div>Stephan<br><div class="gmail_extra"><br><div class="gmail_quote">2017-11-22 12:09 GMT+01:00 Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 22 Nov 2017 00:22:00 -0600<br>
Nick Timkovich <<a href="mailto:prometheus235@gmail.com">prometheus235@gmail.com</a>><br>
wrote:<br>
<span class="">><br>
> Functions are great. I'm a big fan of functions. However,<br>
><br>
> 1. Once there are several that all have the same thing as an argument:<br>
> thing_operation1(thing, arg), thing_operation2(thing, arg)...it's about<br>
> time to bind them together.<br>
> 2. And especially for the heap "soft-datatype": once it's heapified,<br>
> naively modifying it with other methods will ruin the heap invariant. **The<br>
> actual list you pass around can't be treated as a list.**<br>
<br>
</span>A third reason: documentation and discoverability. If I type<br>
help(some_heapified_list) at the prompt, I get the usual documentation<br>
for list methods, not the documentation of heapq functions...<br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888"><br>
Antoine.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br></div></div>