title: What is the time complexity of heapq.nlargest?
body: <p>I was looking at <a href="https://www.youtube.com/watch?v=fYlnfvKVDoM&amp;feature=emb_err_woyt" rel="noreferrer">this pycon talk, 34:30</a> and the speaker says that getting the <code>t</code> largest elements of a list of <code>n</code> elements can be done in <code>O(t + n)</code>.</p>
  <p>How is that possible? My understanding is that creating the heap will be <code>O(n)</code>, but what's the complexity of <code>nlargest</code> itself, is it <code>O(n + t)</code> or <code>O(t)</code> (and what's the actual algorithm)?</p>