From 9ae90c3869273c2cfed8ad285325b458c2203f64 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 4 Aug 2012 17:46:28 +0200 Subject: [PATCH] Make utils.structures.CacheDict subclass collections.MutableMapping instead of deprecated UserDict.DictMixin. --- src/utils/structures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/structures.py b/src/utils/structures.py index 5702836fb..3eb0afdd2 100644 --- a/src/utils/structures.py +++ b/src/utils/structures.py @@ -33,7 +33,7 @@ Data structures for Python. import time import types -import UserDict +import collections from itertools import imap class RingBuffer(object): @@ -418,7 +418,7 @@ class MultiSet(object): return elt in self.d -class CacheDict(UserDict.DictMixin): +class CacheDict(collections.MutableMapping): def __init__(self, max, **kwargs): self.d = dict(**kwargs) self.max = max @@ -443,5 +443,8 @@ class CacheDict(UserDict.DictMixin): def __iter__(self): return iter(self.d) + def __len__(self): + return len(self.d) + # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: