[Python-Dev] heapq method names

François Pinard pinard@iro.umontreal.ca
24 Aug 2002 18:00:40 -0400

Hi, people.

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'.

François Pinard   http://www.iro.umontreal.ca/~pinard