]> granicus.if.org Git - python/commitdiff
Supply a reduce method for pickling.
authorRaymond Hettinger <python@rcn.com>
Mon, 3 Jan 2011 02:44:14 +0000 (02:44 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 3 Jan 2011 02:44:14 +0000 (02:44 +0000)
Lib/collections.py

index f26c73ed0f9b4bbadb16e10798277fa41096a9d5..89a15886f834f2381a10231f591b951bfe166732 100644 (file)
@@ -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: