summaryrefslogtreecommitdiffstats
path: root/Lib/sets.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-08-29 15:13:50 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-08-29 15:13:50 (GMT)
commit1a8d19312107e83fff0dd141a432c5e5c9e7504a (patch)
tree174963dcfd1f49d5494216f713207a2145e7645b /Lib/sets.py
parentfc26c0730c5c337f78150bef255b5f661900f01c (diff)
downloadcpython-1a8d19312107e83fff0dd141a432c5e5c9e7504a.zip
cpython-1a8d19312107e83fff0dd141a432c5e5c9e7504a.tar.gz
cpython-1a8d19312107e83fff0dd141a432c5e5c9e7504a.tar.bz2
Sped _update().
Uses the fast update() method when a dictionary is available.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r--Lib/sets.py9
1 files changed, 9 insertions, 0 deletions
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: