]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Sped _update().
authorRaymond Hettinger <python@rcn.com>
Thu, 29 Aug 2002 15:13:50 +0000 (15:13 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 29 Aug 2002 15:13:50 +0000 (15:13 +0000)
Uses the fast update() method when a dictionary is available.

Lib/sets.py

index 5007709979ebd32ce3537668746ee2c998055946..069be64a7df5be2182a2561588d2b933d020c806 100644 (file)
@@ -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: