Sped _update().

Uses the fast update() method when a dictionary is available.
This commit is contained in:
Raymond Hettinger 2002-08-29 15:13:50 +00:00
parent fc26c0730c
commit 1a8d193121
1 changed files with 9 additions and 0 deletions

View 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: