mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Merge 3.5
This commit is contained in:
		
						commit
						01e4c1175f
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -1338,11 +1338,14 @@ Basic customization
 | 
			
		|||
 | 
			
		||||
   Called by built-in function :func:`hash` and for operations on members of
 | 
			
		||||
   hashed collections including :class:`set`, :class:`frozenset`, and
 | 
			
		||||
   :class:`dict`.  :meth:`__hash__` should return an integer.  The only
 | 
			
		||||
   required property is that objects which compare equal have the same hash
 | 
			
		||||
   value; it is advised to somehow mix together (e.g. using exclusive or) the
 | 
			
		||||
   hash values for the components of the object that also play a part in
 | 
			
		||||
   comparison of objects.
 | 
			
		||||
   :class:`dict`.  :meth:`__hash__` should return an integer. The only required
 | 
			
		||||
   property is that objects which compare equal have the same hash value; it is
 | 
			
		||||
   advised to mix together the hash values of the components of the object that
 | 
			
		||||
   also play a part in comparison of objects by packing them into a tuple and
 | 
			
		||||
   hashing the tuple. Example::
 | 
			
		||||
 | 
			
		||||
       def __hash__(self):
 | 
			
		||||
           return hash((self.name, self.nick, self.color))
 | 
			
		||||
 | 
			
		||||
   .. note::
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue