From d9c9151a53b1f0e65370da7ed08d216a5cda8062 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 21 Aug 2002 13:20:51 +0000 Subject: 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(). --- Lib/sets.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v0.12