summaryrefslogtreecommitdiffstats
path: root/Lib/sets.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-11-13 19:34:26 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-11-13 19:34:26 (GMT)
commitcd58b8f532e7d0337b250e60f5d3d5b073f0479c (patch)
tree555d5d08b73436097ae4894b18efae94fdc03c63 /Lib/sets.py
parent66abcee948e9183edd807f8c0ce3c2a721cdafd0 (diff)
downloadcpython-cd58b8f532e7d0337b250e60f5d3d5b073f0479c.zip
cpython-cd58b8f532e7d0337b250e60f5d3d5b073f0479c.tar.gz
cpython-cd58b8f532e7d0337b250e60f5d3d5b073f0479c.tar.bz2
Add getstate and setstate implementation to concrete set classes.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r--Lib/sets.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/sets.py b/Lib/sets.py
index a05c66f..5dac370a 100644
--- a/Lib/sets.py
+++ b/Lib/sets.py
@@ -366,6 +366,11 @@ class ImmutableSet(BaseSet):
self._hashcode = self._compute_hash()
return self._hashcode
+ def __getstate__(self):
+ return self._data, self._hashcode
+
+ def __setstate__(self, state):
+ self._data, self._hashcode = state
class Set(BaseSet):
""" Mutable set class."""
@@ -380,6 +385,13 @@ class Set(BaseSet):
if iterable is not None:
self._update(iterable)
+ def __getstate__(self):
+ # getstate's results are ignored if it is not
+ return self._data,
+
+ def __setstate__(self, data):
+ self._data, = data
+
def __hash__(self):
"""A Set cannot be hashed."""
# We inherit object.__hash__, so we must deny this explicitly