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.
One reason is that I don't understand the concept of a heap completely, but I do understand how Guido used it.
Now, beside his kinda crazy example, what would you use the heapq
module for?
Must it always be related to sorting or minimum value? Is it only something you use because it's faster than other approaches? Or can you do really elegant things that you can't do without?