What would you use the heapq Python module for in real life?

前端 未结 3 1116
栀梦
栀梦 2021-02-02 16:59

After reading Guido\'s Sorting a million 32-bit integers in 2MB of RAM using Python, I discovered the heapq module, but the concept is pretty abstract to me.

<
3条回答
  •  旧巷少年郎
    2021-02-02 17:32

    This was an accidental discovery of me by trying to see how could I implement the Counter Module in Python 2.6. Just have a look into the implementation and usage of collections.Counter. This is actually implemented through heapq.

提交回复
热议问题