Raymond Hettinger
4901a1f267
Add key= argument to heapq.nsmallest() and heapq.nlargest().
2004-12-02 08:59:14 +00:00
Raymond Hettinger
e1defa4175
Fix argument order in pure python version of nsmallest() and nlargest().
2004-11-29 05:54:48 +00:00
Raymond Hettinger
855d9a985b
Plug a leak and beef-up test coverage.
2004-09-28 00:03:54 +00:00
Tim Peters
27f883687b
Whitespace normalization.
2004-07-08 04:22:35 +00:00
Neal Norwitz
d7be118626
Exercise some error conditions
2004-07-08 01:56:46 +00:00
Raymond Hettinger
aefde435ef
Reverse argument order for nsmallest() and nlargest().
...
Reads better when the iterable is a generator expression.
2004-06-15 23:53:35 +00:00
Raymond Hettinger
2e3dfaf707
Install C version of heapq.nsmallest().
2004-06-13 05:26:33 +00:00
Raymond Hettinger
b25aa36f83
Improve the memory performance and speed of heapq.nsmallest() by using
...
an alternate algorithm when the number of selected items is small
relative to the full iterable.
2004-06-12 08:33:36 +00:00
Raymond Hettinger
bce036b49e
Convert test_heapq.py to unittests.
2004-06-10 05:07:18 +00:00
Raymond Hettinger
33ecffb65a
SF patch #969791 : Add nlargest() and nsmallest() to heapq.
2004-06-10 05:03:17 +00:00
Raymond Hettinger
065c06a622
Add another test which exercises the whole suite with a
...
heapsort and verifies the result against list.sort().
2002-12-07 10:33:42 +00:00
Tim Peters
0cd53a6c37
Added new heapreplace(heap, item) function, to pop (and return) the
...
currently-smallest value, and add item, in one gulp. See the second
N-Best algorithm in the test suite for a natural use.
2002-08-03 10:10:10 +00:00
Tim Peters
aa7d24319e
Minor fiddling, including a simple class to implement a heap iterator
...
in the test file. I have docs for heapq.heapify ready to check in, but
Jack appears to have left behind a stale lock in the Doc/lib directory.
2002-08-03 02:11:26 +00:00
Tim Peters
28c25527c2
Hmm! I thought I checked this in before! Oh well.
...
Added new heapify() function, which transforms an arbitrary list into a
heap in linear time; that's a fundamental tool for using heaps in real
life <wink>.
Added heapyify() test. Added a "less naive" N-best algorithm to the test
suite, and noted that this could actually go much faster (building on
heapify()) if we had max-heaps instead of min-heaps (the iterative method
is appropriate when all the data isn't known in advance, but when it is
known in advance the tradeoffs get murkier).
2002-08-02 21:48:06 +00:00
Tim Peters
d2cf1ab0e2
check_invariant(): Use the same child->parent "formula" used by heapq.py.
2002-08-02 19:41:54 +00:00
Tim Peters
d9ea39db84
Don't use true division where int division was intended. For that matter,
...
don't use division at all.
2002-08-02 19:16:44 +00:00
Guido van Rossum
0b19178736
Adding the heap queue algorithm, per discussion in python-dev last
...
week.
2002-08-02 18:29:53 +00:00