]> granicus.if.org Git - python/commitdiff
Now that __init__ transforms set elements, we know that all of the
authorRaymond Hettinger <python@rcn.com>
Wed, 21 Aug 2002 13:20:51 +0000 (13:20 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 21 Aug 2002 13:20:51 +0000 (13:20 +0000)
elements are hashable, so we can use dict.update() or dict.copy()
for a C speed Set.copy().

Lib/sets.py

index bb4428064d1084858369b614177015cb1a3cb214..eeef0e8087febfb12d5181193c79650bb5677753 100644 (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