[Python-checkins] cpython: Minor clean-ups.

raymond.hettinger python-checkins at python.org
Mon Jun 2 08:40:08 CEST 2014


http://hg.python.org/cpython/rev/ca2539818a6a
changeset:   90959:ca2539818a6a
user:        Raymond Hettinger <python at rcn.com>
date:        Sun Jun 01 23:40:01 2014 -0700
summary:
  Minor clean-ups.

files:
  Lib/heapq.py |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Lib/heapq.py b/Lib/heapq.py
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -397,7 +397,7 @@
         except StopIteration:
             _heappop(h)
     if h:
-        key_value, order, value,  next = h[0]
+        key_value, order, value, next = h[0]
         yield value
         yield from next.__self__
 
@@ -413,7 +413,7 @@
 #                                   number of comparisons
 #    n inputs     k-extreme values  (average of 5 trials)   % more than min()
 # -------------   ----------------  ---------------------   -----------------
-#      1,000           100                  3,317               133.2%
+#      1,000           100                  3,317               233.2%
 #     10,000           100                 14,046                40.5%
 #    100,000           100                105,749                 5.7%
 #  1,000,000           100              1,007,751                 0.8%
@@ -496,6 +496,8 @@
     # When key is none, use simpler decoration
     if key is None:
         it = iter(iterable)
+        # put the range(n) first so that zip() doesn't
+        # consume one too many elements from the iterator
         result = [(elem, i) for i, elem in zip(range(n), it)]
         if not result:
             return result
@@ -594,4 +596,4 @@
 if __name__ == "__main__":
 
     import doctest
-    doctest.testmod()
+    print(doctest.testmod())

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list