Even DRYer FrozenOrderedDict class

This commit is contained in:
Eeo Jun 2016-04-27 20:30:17 +08:00
parent de2d597dfe
commit 6747f2d84e
1 changed files with 3 additions and 5 deletions

View File

@ -4,9 +4,10 @@ import functools
class frozendict(collections.Mapping):
dict_cls = dict
def __init__(self, *args, **kwargs):
self._dict = dict(*args, **kwargs)
self._dict = self.dict_cls(*args, **kwargs)
self._hash = None
def __getitem__(self, key):
@ -40,7 +41,4 @@ class FrozenOrderedDict(frozendict):
It is an immutable wrapper around ordered dictionaries that implements the complete :py:class:`collections.Mapping`
interface. It can be used as a drop-in replacement for dictionaries where immutability and ordering are desired.
"""
def __init__(self, *args, **kwargs):
self._dict = collections.OrderedDict(*args, **kwargs)
self._hash = None
dict_cls = collections.OrderedDict