Issue #21421: Add __slots__ to the MappingViews ABCs.

This commit is contained in:
Raymond Hettinger 2014-05-03 19:06:32 -07:00
parent 90e9338383
commit 3170d1cccb
2 changed files with 11 additions and 0 deletions

View file

@ -440,6 +440,8 @@ Mapping.register(mappingproxy)
class MappingView(Sized):
__slots__ = '_mapping',
def __init__(self, mapping):
self._mapping = mapping
@ -452,6 +454,8 @@ class MappingView(Sized):
class KeysView(MappingView, Set):
__slots__ = ()
@classmethod
def _from_iterable(self, it):
return set(it)
@ -467,6 +471,8 @@ KeysView.register(dict_keys)
class ItemsView(MappingView, Set):
__slots__ = ()
@classmethod
def _from_iterable(self, it):
return set(it)
@ -489,6 +495,8 @@ ItemsView.register(dict_items)
class ValuesView(MappingView):
__slots__ = ()
def __contains__(self, value):
for key in self._mapping:
if value == self._mapping[key]: