mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Issue #21421: Add __slots__ to the MappingViews ABCs.
This commit is contained in:
		
							parent
							
								
									90e9338383
								
							
						
					
					
						commit
						3170d1cccb
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		| 
						 | 
					@ -440,6 +440,8 @@ def __ne__(self, other):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MappingView(Sized):
 | 
					class MappingView(Sized):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __slots__ = '_mapping',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, mapping):
 | 
					    def __init__(self, mapping):
 | 
				
			||||||
        self._mapping = mapping
 | 
					        self._mapping = mapping
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -452,6 +454,8 @@ def __repr__(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class KeysView(MappingView, Set):
 | 
					class KeysView(MappingView, Set):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __slots__ = ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def _from_iterable(self, it):
 | 
					    def _from_iterable(self, it):
 | 
				
			||||||
        return set(it)
 | 
					        return set(it)
 | 
				
			||||||
| 
						 | 
					@ -467,6 +471,8 @@ def __iter__(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ItemsView(MappingView, Set):
 | 
					class ItemsView(MappingView, Set):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __slots__ = ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def _from_iterable(self, it):
 | 
					    def _from_iterable(self, it):
 | 
				
			||||||
        return set(it)
 | 
					        return set(it)
 | 
				
			||||||
| 
						 | 
					@ -489,6 +495,8 @@ def __iter__(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ValuesView(MappingView):
 | 
					class ValuesView(MappingView):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __slots__ = ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __contains__(self, value):
 | 
					    def __contains__(self, value):
 | 
				
			||||||
        for key in self._mapping:
 | 
					        for key in self._mapping:
 | 
				
			||||||
            if value == self._mapping[key]:
 | 
					            if value == self._mapping[key]:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +73,9 @@ Library
 | 
				
			||||||
  Decimal.quantize() method in the Python version.  It had never been
 | 
					  Decimal.quantize() method in the Python version.  It had never been
 | 
				
			||||||
  present in the C version.
 | 
					  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
 | 
					- Issue #21101: Eliminate double hashing in the C speed-up code for
 | 
				
			||||||
  collections.Counter().
 | 
					  collections.Counter().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue