A generic priority queue for Python

后端 未结 12 484
面向向阳花
面向向阳花 2020-12-13 03:27

I need to use a priority queue in my Python code, and:

  • am looking for any fast implementations for priority queues
  • optimally, I\'d li
12条回答
  •  不知归路
    2020-12-13 04:15

    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.

提交回复
热议问题