From: Raymond Hettinger Date: Mon, 3 Jan 2011 02:44:14 +0000 (+0000) Subject: Supply a reduce method for pickling. X-Git-Tag: v3.2rc1~237 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff72816b5fad9909c9e8ba4144d258b4595bbaca;p=python Supply a reduce method for pickling. --- diff --git a/Lib/collections.py b/Lib/collections.py index f26c73ed0f..89a15886f8 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -539,6 +539,9 @@ class Counter(dict): 'Like dict.copy() but returns a Counter instance instead of a dict.' return Counter(self) + def __reduce__(self): + return self.__class__, (dict(self),) + def __delitem__(self, elem): 'Like dict.__delitem__() but does not raise KeyError for missing values.' if elem in self: