Document that object.__eq__ implements
a is b
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
assignee = 'https://github.com/brettcannon' closed_at = <Date 2020-10-22.01:33:19.923> created_at = <Date 2020-10-02.15:22:02.868> labels = ['3.8', '3.9', '3.10', 'docs'] title = 'Document that object.__eq__ implements `a is b`' updated_at = <Date 2020-12-08.18:00:36.499> user = 'https://github.com/brettcannon'
activity = <Date 2020-12-08.18:00:36.499> actor = 'terry.reedy' assignee = 'brett.cannon' closed = True closed_date = <Date 2020-10-22.01:33:19.923> closer = 'terry.reedy' components = ['Documentation'] creation = <Date 2020-10-02.15:22:02.868> creator = 'brett.cannon' dependencies =  files =  hgrepos =  issue_num = 41910 keywords = ['patch'] message_count = 9.0 messages = ['377816', '377845', '379264', '379265', '379266', '379267', '379269', '382744', '382754', '382755'] nosy_count = 4.0 nosy_names = ['brett.cannon', 'terry.reedy', 'docs@python', 'miss-islington'] pr_nums = ['22874', '22876', '22877', '23695', '23697', '23698'] priority = 'low' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue41910' versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']
The text was updated successfully, but these errors were encountered:
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.