[Python-checkins] python/dist/src/Lib/test test_heapq.py,1.9,1.10

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Jun 12 04:33:38 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19530/test

Modified Files:
	test_heapq.py 
Log Message:
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.



Index: test_heapq.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_heapq.py	10 Jun 2004 05:07:18 -0000	1.9
--- test_heapq.py	12 Jun 2004 08:33:36 -0000	1.10
***************
*** 93,96 ****
--- 93,97 ----
          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):




More information about the Python-checkins mailing list