[Python-Dev] heapq method names

Guido van Rossum guido@python.org
Sat, 24 Aug 2002 20:03:59 -0400

> In the `heapq' module, I'm a little bothered by the fact modules names have
> `heap' as a prefix in their name.  If the methods have been installed as
> standard list methods, it would be quite understandable, but it has been
> decided otherwise.
> The most usual way of using a module is:
>     import MODULE
>      ...
> rather than:
>     from MODULE import METHOD
>      ...
> and we should name METHODs accordingly, not repeating the MODULE as prefix.
> This is a rather common usage, almost everywhere in the Python library.
> So my suggestion of changing now, before `heapq' gets released for real:
>     heappush -> push
>     heappop -> pop
>     heapreplace -> replace
> I guess that `heapify' is OK as it stands.
> The example should be changed accordingly, that is, using `import heapq'
> instead of `from heapq import such-and-such', using `heapq.push' instead of
> `heappush' and `heapq.pop' instead of `heappop'.

-1.  The nmes 'push', 'pop' and 'replace' are too generic.  The module
seems to "invite" the ``from heapq import heappush, heappop'' syntax,
and I'd like to honor that.

--Guido van Rossum (home page: http://www.python.org/~guido/)