diff options
author | Raymond Hettinger <python@rcn.com> | 2014-05-04 02:06:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2014-05-04 02:06:32 (GMT) |
commit | 3170d1cccb15d7ad94658944e3aba1a1e753adbf (patch) | |
tree | 356e8fdcfb023bca43eb005eabebfa3e28c6a6dd | |
parent | 90e93383830cb7276d33fff7e670516d78337121 (diff) | |
download | cpython-3170d1cccb15d7ad94658944e3aba1a1e753adbf.zip cpython-3170d1cccb15d7ad94658944e3aba1a1e753adbf.tar.gz cpython-3170d1cccb15d7ad94658944e3aba1a1e753adbf.tar.bz2 |
Issue #21421: Add __slots__ to the MappingViews ABCs.
-rw-r--r-- | Lib/_collections_abc.py | 8 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py index faa1ff2..62817236 100644 --- a/Lib/_collections_abc.py +++ b/Lib/_collections_abc.py @@ -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]: @@ -73,6 +73,9 @@ Library 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(). |