• Raymond Hettinger's avatar
    Issue #21424: Optimize heaqp.nlargest() to make fewer tuple comparisons. · 277842ef
    Raymond Hettinger yazdı
    Consolidates the logic for nlargest() into a single function so that
    decoration tuples (elem,order) or (key, order, elem) only need to
    be formed when a new element is added to the heap.  Formerly, a tuple
    was created for every element regardless of whether it was added to
    the heap.
    
    The change reduces the number of tuples created, the number of ordering
    integers created, and total number of tuple comparisons.
    277842ef
_heapqmodule.c 19.6 KB