mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Make utils.structures.CacheDict subclass collections.MutableMapping instead of deprecated UserDict.DictMixin.
This commit is contained in:
parent
6514db9b3f
commit
9ae90c3869
@ -33,7 +33,7 @@ Data structures for Python.
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
import UserDict
|
import collections
|
||||||
from itertools import imap
|
from itertools import imap
|
||||||
|
|
||||||
class RingBuffer(object):
|
class RingBuffer(object):
|
||||||
@ -418,7 +418,7 @@ class MultiSet(object):
|
|||||||
return elt in self.d
|
return elt in self.d
|
||||||
|
|
||||||
|
|
||||||
class CacheDict(UserDict.DictMixin):
|
class CacheDict(collections.MutableMapping):
|
||||||
def __init__(self, max, **kwargs):
|
def __init__(self, max, **kwargs):
|
||||||
self.d = dict(**kwargs)
|
self.d = dict(**kwargs)
|
||||||
self.max = max
|
self.max = max
|
||||||
@ -443,5 +443,8 @@ class CacheDict(UserDict.DictMixin):
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.d)
|
return iter(self.d)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.d)
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
Reference in New Issue
Block a user