[Python-ideas] Adding a thin wrapper class around the functions in stdlib.heapq
Stephan Houben
stephanh42 at gmail.com
Wed Nov 22 06:23:54 EST 2017
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 at pitrou.net>:
> On Wed, 22 Nov 2017 00:22:00 -0600
> Nick Timkovich <prometheus235 at gmail.com>
> wrote:
> >
> > Functions are great. I'm a big fan of functions. However,
> >
> > 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.
> > 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 at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171122/4003599a/attachment.html>
More information about the Python-ideas
mailing list