Terry J. Reedy <tjre...@udel.edu> added the comment:

The word 'object' in this section is a bit confusing because it refers to any 
Python object, not to base class 'object' or an instance thereof.  I suspect 
that this usage predates the introduction of the latter in 2.2.

This interpretation is required for sentences like "By default, __ne__() 
delegates to __eq__() and inverts the result unless it is NotImplemented." and 
"If a class does not define an __eq__() method ..." (in the __hash__ entry) to 
make sense.  I think that the meaning of 'object' should be stipulated at the 
top of the section and mention the existence of base class 'object', and maybe 
list which of the following methods it has, and that they are inherited by 
subclasses.

The base class __eq__ implementation is implied in this paragraph in the 
__hash__ entry.

"User-defined classes have __eq__() and __hash__() methods by default; with 
them, all objects compare unequal (except with themselves) and x.__hash__() 
returns an appropriate value such that x == y implies both that x is y and 
hash(x) == hash(y)."

I think it worthwhile explaining that user classes get these defaults by 
inheriting them (and others) from 'object', and that the implication follows 
from inheriting a particular base class implementation of __eq__.  To put it 
another way, I believe the quoted paragraph makes the  definition a Python 
requirement rather than just a CPython implementation detail.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41910>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to