diff options
author | Raymond Hettinger <python@rcn.com> | 2004-06-12 08:33:36 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-06-12 08:33:36 (GMT) |
commit | b25aa36f83a3cd2200f2bc479e594458e27794a3 (patch) | |
tree | afdd8051a7b152562b6a4a006fe7fe814113021e /Lib/test/test_heapq.py | |
parent | 2e6694086f07d293d1907891f68cec6076d44f73 (diff) | |
download | cpython-b25aa36f83a3cd2200f2bc479e594458e27794a3.zip cpython-b25aa36f83a3cd2200f2bc479e594458e27794a3.tar.gz cpython-b25aa36f83a3cd2200f2bc479e594458e27794a3.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r-- | Lib/test/test_heapq.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index 944b17d..1cdaabe 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -92,6 +92,7 @@ class TestHeap(unittest.TestCase): def test_nsmallest(self): data = [random.randrange(2000) for i in range(1000)] self.assertEqual(nsmallest(data, 400), sorted(data)[:400]) + self.assertEqual(nsmallest(data, 50), sorted(data)[:50]) def test_largest(self): data = [random.randrange(2000) for i in range(1000)] |