changeset: 90555:2c6a231e2c1e user: Raymond Hettinger date: Sat May 03 19:06:32 2014 -0700 files: Lib/_collections_abc.py Misc/NEWS description: Issue #21421: Add __slots__ to the MappingViews ABCs. diff -r 2b88baf64151 -r 2c6a231e2c1e Lib/_collections_abc.py --- a/Lib/_collections_abc.py Sat May 03 18:45:54 2014 -0700 +++ b/Lib/_collections_abc.py Sat May 03 19:06:32 2014 -0700 @@ -440,6 +440,8 @@ class MappingView(Sized): + __slots__ = '_mapping', + def __init__(self, mapping): self._mapping = mapping @@ -452,6 +454,8 @@ class KeysView(MappingView, Set): + __slots__ = () + @classmethod def _from_iterable(self, it): return set(it) @@ -467,6 +471,8 @@ class ItemsView(MappingView, Set): + __slots__ = () + @classmethod def _from_iterable(self, it): return set(it) @@ -489,6 +495,8 @@ class ValuesView(MappingView): + __slots__ = () + def __contains__(self, value): for key in self._mapping: if value == self._mapping[key]: diff -r 2b88baf64151 -r 2c6a231e2c1e Misc/NEWS --- a/Misc/NEWS Sat May 03 18:45:54 2014 -0700 +++ b/Misc/NEWS Sat May 03 19:06:32 2014 -0700 @@ -73,6 +73,9 @@ Decimal.quantize() method in the Python version. It had never been present in the C version. +- Issue #21421: Add __slots__ to the MappingViews ABC. + Patch by Josh Rosenberg. + - Issue #21101: Eliminate double hashing in the C speed-up code for collections.Counter().