-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Document that object.__eq__ implements a is b
#86076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you look at the data model |
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. |
Brett, I presume you want this closed. |
Thanks, Terry! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: