mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	bpo-41910: specify the default implementations of object.__eq__ and object.__ne__ (GH-22874)
See Objects/typeobject.c:object_richcompare() for the implementation of this in CPython. Automerge-Triggered-By: GH:brettcannon
This commit is contained in:
		
							parent
							
								
									b451b0e9a7
								
							
						
					
					
						commit
						3c69f0c933
					
				
					 2 changed files with 9 additions and 6 deletions
				
			
		| 
						 | 
					@ -1395,12 +1395,14 @@ Basic customization
 | 
				
			||||||
   context (e.g., in the condition of an ``if`` statement), Python will call
 | 
					   context (e.g., in the condition of an ``if`` statement), Python will call
 | 
				
			||||||
   :func:`bool` on the value to determine if the result is true or false.
 | 
					   :func:`bool` on the value to determine if the result is true or false.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   By default, :meth:`__ne__` delegates to :meth:`__eq__` and
 | 
					   By default, ``object`` implements :meth:`__eq__` by using ``is``, returning
 | 
				
			||||||
   inverts the result unless it is ``NotImplemented``.  There are no other
 | 
					   ``NotImplemented`` in the case of a false comparison:
 | 
				
			||||||
   implied relationships among the comparison operators, for example,
 | 
					   ``True if x is y else NotImplemented``. For :meth:`__ne__`, by default it
 | 
				
			||||||
   the truth of ``(x<y or x==y)`` does not imply ``x<=y``.
 | 
					   delegates to :meth:`__eq__` and inverts the result unless it is
 | 
				
			||||||
   To automatically generate ordering operations from a single root operation,
 | 
					   ``NotImplemented``.  There are no other implied relationships among the
 | 
				
			||||||
   see :func:`functools.total_ordering`.
 | 
					   comparison operators or default implementations; for example, the truth of
 | 
				
			||||||
 | 
					   ``(x<y or x==y)`` does not imply ``x<=y``. To automatically generate ordering
 | 
				
			||||||
 | 
					   operations from a single root operation, see :func:`functools.total_ordering`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   See the paragraph on :meth:`__hash__` for
 | 
					   See the paragraph on :meth:`__hash__` for
 | 
				
			||||||
   some important notes on creating :term:`hashable` objects which support
 | 
					   some important notes on creating :term:`hashable` objects which support
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					Document the default implementation of `object.__eq__`.
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue