From: Raymond Hettinger Date: Wed, 21 Aug 2002 13:20:51 +0000 (+0000) Subject: Now that __init__ transforms set elements, we know that all of the X-Git-Tag: v2.3c1~4369 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9c9151a53b1f0e65370da7ed08d216a5cda8062;p=python 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(). --- diff --git a/Lib/sets.py b/Lib/sets.py index bb4428064d..eeef0e8087 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