summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-08-21 13:20:51 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-08-21 13:20:51 (GMT)
commitd9c9151a53b1f0e65370da7ed08d216a5cda8062 (patch)
tree5932b4b3e850b8b375d9a0333293522bc4ac2d7f /Lib
parentc3e61e5c52213cb37ac48439e555728dd88dfcb2 (diff)
downloadcpython-d9c9151a53b1f0e65370da7ed08d216a5cda8062.zip
cpython-d9c9151a53b1f0e65370da7ed08d216a5cda8062.tar.gz
cpython-d9c9151a53b1f0e65370da7ed08d216a5cda8062.tar.bz2
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().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/sets.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/sets.py b/Lib/sets.py
index bb44280..eeef0e8 100644
--- a/Lib/sets.py
+++ b/Lib/sets.py
@@ -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