From 1a8d19312107e83fff0dd141a432c5e5c9e7504a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 29 Aug 2002 15:13:50 +0000 Subject: Sped _update(). Uses the fast update() method when a dictionary is available. --- Lib/sets.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/sets.py b/Lib/sets.py index 5007709..069be64 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: -- cgit v0.12