Now that __init__ transforms set elements, we know that all of the

elements are hashable, so we can use dict.update() or dict.copy()
for a C speed Set.copy().
This commit is contained in:
Raymond Hettinger 2002-08-21 13:20:51 +00:00
parent c3e61e5c52
commit d9c9151a53
1 changed files with 3 additions and 1 deletions

View File

@ -133,7 +133,9 @@ class BaseSet(object):
def copy(self):
"""Return a shallow copy of a set."""
return self.__class__(self)
result = self.__class__([])
result._data.update(self._data)
return result
__copy__ = copy # For the copy module