[Python-checkins] r60674 - python/trunk/Lib/_abcoll.py

raymond.hettinger python-checkins at python.org
Sat Feb 9 00:02:27 CET 2008


Author: raymond.hettinger
Date: Sat Feb  9 00:02:27 2008
New Revision: 60674

Modified:
   python/trunk/Lib/_abcoll.py
Log:
Speed-up __iter__() mixin method.

Modified: python/trunk/Lib/_abcoll.py
==============================================================================
--- python/trunk/Lib/_abcoll.py	(original)
+++ python/trunk/Lib/_abcoll.py	Sat Feb  9 00:02:27 2008
@@ -496,13 +496,13 @@
 
     def __iter__(self):
         i = 0
-        while True:
-            try:
+        try:
+            while True:
                 v = self[i]
-            except IndexError:
-                break
-            yield v
-            i += 1
+                yield v
+                i += 1
+        except IndexError:
+            return
 
     def __contains__(self, value):
         for v in self:


More information about the Python-checkins mailing list