
I thought the purpose of heapq was to have a ready-made example for instructors on how an API can be improved by applying object-oriented techniques. ;-)
I think adding a HeapQueue class would be a great idea. Obviously the existing functions would need to continue existing for backward compatibility.
Stephan
2017-11-22 12:09 GMT+01:00 Antoine Pitrou solipsis@pitrou.net:
On Wed, 22 Nov 2017 00:22:00 -0600 Nick Timkovich prometheus235@gmail.com wrote:
Functions are great. I'm a big fan of functions. However,
- 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.**
A third reason: documentation and discoverability. If I type help(some_heapified_list) at the prompt, I get the usual documentation for list methods, not the documentation of heapq functions...
Regards
Antoine.
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/