Python: Implementing a priority queue.