mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue