Hello,
I need to use a priority queue in my Python code. Looking around for something efficient, I came upon heapq. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify what comparison operators it needs.
Besides, heapq
seems to be implemented in Python, so it's not fast.
Are you aware of any fast implementations for priority queues in Python ? Optimally, I'd like the queue to be generic (i.e. work well for any object with a specified comparison operator).
Thanks in advance
Update:
Re comparison in heapq
, I can either use a (priority, object)
as Charlie Martin suggests, or just implement __cmp__
for my object.
I'm still looking for something faster than heapq
.