From: Raymond Hettinger Date: Fri, 8 Feb 2008 23:02:27 +0000 (+0000) Subject: Speed-up __iter__() mixin method. X-Git-Tag: v2.6a1~227 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18a1ffcda373fad5f60c187217d7c2125bccf005;p=thirdparty%2FPython%2Fcpython.git Speed-up __iter__() mixin method. --- diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 6c27e66be5f4..30ec7d4280cd 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -496,13 +496,13 @@ class Sequence: 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: