Note that it's common to use the bisect module in the from bisect import bisect_right, bisect, insort way too, rather than spell out bisect.bisect (etc) each time. That's "the other" module that (conceptually) adds new methods to lists. If you want simpler names, I'm finding this little module quite pleasant to use: """ import heapq class Heap(list): def __init__(self, iterable=[]): self.extend(iterable) push = heapq.heappush popmin = heapq.heappop replace = heapq.heapreplace heapify = heapq.heapify """ That is, it creates a Heap type that's just a list with some extra methods. Note that the "pop" method can't be named "pop"! If you try, you'll soon get unbounded recursion because the heapq functions need list.pop to access the list meaning of "pop". Guido suggested a long time ago that such a class could be added to heapq, and I like it a lot in real life.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4