From 18a1ffcda373fad5f60c187217d7c2125bccf005 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 8 Feb 2008 23:02:27 +0000 Subject: [PATCH] Speed-up __iter__() mixin method. --- Lib/_abcoll.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 6c27e66be5..30ec7d4280 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: -- 2.40.0