]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21421: Add __slots__ to the MappingViews ABCs.
authorRaymond Hettinger <python@rcn.com>
Sun, 4 May 2014 02:06:32 +0000 (19:06 -0700)
committerRaymond Hettinger <python@rcn.com>
Sun, 4 May 2014 02:06:32 +0000 (19:06 -0700)
Lib/_collections_abc.py
Misc/NEWS

index faa1ff22ff401b6d13d0016d71deef4d764697ff..62817236f9a86c731facecc2534cca68450ce820 100644 (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]:
index 18c943e720d58c627d8049ff43c57a28a15e005c..c61821223b2375f24008c807950074a0dda02da5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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().