Priorityq – Another python priority queue library
panyam.wordpress.com
panyam.wordpress.com
Consider the python heapq module. It directly works on a list, maintaining the heap invariant. So you (the dev) can freely modify the underlying list invalidating the heap invariant. But if the (heap) storage returned handle objects that encapsulated the position within the heap, then the client can just update the priority of the value pointed by the handle without knowing anything about how the heap is implemented.
So linear increase in memory usage (for the map) but fast retrievals. I plan to try this out with other kinds of heap implementations soon.
Would love to get some feedback.