]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Large code rearrangement to use better algorithms, in the sense of needing
authorTim Peters <tim.peters@gmail.com>
Sat, 3 Aug 2002 09:56:52 +0000 (09:56 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 3 Aug 2002 09:56:52 +0000 (09:56 +0000)
commit657fe38241a7f072bdbf040a7bd05df96f326c5c
tree1cea4e21c0bb515702af1cd180ff350cfc1b9ebf
parent6bdbc9e0b1d17e637236dc71b3fa775c23dd1d40
Large code rearrangement to use better algorithms, in the sense of needing
substantially fewer array-element compares.  This is best practice as of
Kntuh Volume 3 Ed 2, and the code is actually simpler this way (although
the key idea may be counter-intuitive at first glance!  breaking out of
a loop early loses when it costs more to try to get out early than getting
out early saves).
Also added a comment block explaining the difference and giving some real
counts; demonstrating that heapify() is more efficient than repeated
heappush(); and emphasizing the obvious point thatlist.sort() is more
efficient if what you really want to do is sort.
Lib/heapq.py