Skip to content

Commit ff72816

Browse files
committed
Supply a reduce method for pickling.
1 parent 426e052 commit ff72816

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/collections.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ def copy(self):
539539
'Like dict.copy() but returns a Counter instance instead of a dict.'
540540
return Counter(self)
541541

542+
def __reduce__(self):
543+
return self.__class__, (dict(self),)
544+
542545
def __delitem__(self, elem):
543546
'Like dict.__delitem__() but does not raise KeyError for missing values.'
544547
if elem in self:

0 commit comments

Comments
 (0)