This is out of curiosity about the nsmallest and nlargest methods of heapq.py module in python.
I was reading it here in the docs.
The documentation doesn't say how it does so (nsmalles/nlargest) on any iterable.
This might be a stupid question, but can I assume that these methods internally create a heap of the iterable data structure (may be using 'heapify' method) and then return the n smallest/largest elements?
Just want to confirm my conclusion. thanks!