summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_heapq.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-05-11 08:55:46 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-05-11 08:55:46 (GMT)
commit277842eff12eba1ceeeba1cee93db3ec99d5c95a (patch)
treec88048d92f55d57585192c1274d8476d7ffc9ac9 /Lib/test/test_heapq.py
parentd6a46ae7059a5597aab614226f345bfb7dd67c16 (diff)
downloadcpython-277842eff12eba1ceeeba1cee93db3ec99d5c95a.zip
cpython-277842eff12eba1ceeeba1cee93db3ec99d5c95a.tar.gz
cpython-277842eff12eba1ceeeba1cee93db3ec99d5c95a.tar.bz2
Issue #21424: Optimize heaqp.nlargest() to make fewer tuple comparisons.
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.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r--Lib/test/test_heapq.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index b5a2fd8..1735a19 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -13,7 +13,7 @@ c_heapq = support.import_fresh_module('heapq', fresh=['_heapq'])
# _heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when
# _heapq is imported, so check them there
func_names = ['heapify', 'heappop', 'heappush', 'heappushpop',
- 'heapreplace', '_nlargest', '_nsmallest']
+ 'heapreplace', '_nsmallest']
class TestModules(TestCase):
def test_py_functions(self):