mirror of https://github.com/python/cpython
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:
parent
c3e61e5c52
commit
d9c9151a53
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue