I need to use a priority queue in my Python code, and:
Looking around for something efficient, I came upon heapq, but:
heapq
, which is implemented in native Python, so it's not fast.heapq
, I can either use a (priority, object)
as Charlie Martin suggests, or just implement __cmp__
for my object. You can use Queue.PriorityQueue.
Recall that Python isn't strongly typed, so you can save anything you like: just make a tuple of (priority, thing)
and you're set.