From: Raymond Hettinger Date: Thu, 29 Aug 2002 15:13:50 +0000 (+0000) Subject: Sped _update(). X-Git-Tag: v2.3c1~4261 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a8d19312107e83fff0dd141a432c5e5c9e7504a;p=thirdparty%2FPython%2Fcpython.git Sped _update(). Uses the fast update() method when a dictionary is available. --- diff --git a/Lib/sets.py b/Lib/sets.py index 5007709979eb..069be64a7df5 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -310,6 +310,15 @@ class BaseSet(object): def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data + + # Use the fast update() method when a dictionary is available. + if isinstance(iterable, BaseSet): + data.update(iterable._data) + return + if isinstance(iterable, dict): + data.update(iterable) + return + value = True it = iter(iterable) while True: