Why do we need separate functions for == and != ? Isn't this supposed to be negation of each other?
Hello, As I remember, __ne__ is implemented by default as *not *__eq__() in the base for hashable classes. Among the reasons to have a separate __ne__ may be implementation efficiency. Another is symmetry and completeness. Read the docs about the minimum a class must to do be: - hashable - sortable On Fri, Dec 27, 2019 at 12:00 PM Siddharth Prajosh <sprajosh@gmail.com> wrote:
Why do we need separate functions for == and != ?
Isn't this supposed to be negation of each other? _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5M6RJN... Code of Conduct: http://python.org/psf/codeofconduct/
-- Juancarlo *Añez*
Thank you for the clarification. On Fri, 27 Dec, 2019, 22:23 Juancarlo Añez, <apalala@gmail.com> wrote:
Hello,
As I remember, __ne__ is implemented by default as *not *__eq__() in the base for hashable classes. Among the reasons to have a separate __ne__ may be implementation efficiency. Another is symmetry and completeness.
Read the docs about the minimum a class must to do be:
- hashable - sortable
On Fri, Dec 27, 2019 at 12:00 PM Siddharth Prajosh <sprajosh@gmail.com> wrote:
Why do we need separate functions for == and != ?
Isn't this supposed to be negation of each other? _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5M6RJN... Code of Conduct: http://python.org/psf/codeofconduct/
-- Juancarlo *Añez*
participants (3)
-
Juancarlo Añez
-
Serhiy Storchaka
-
Siddharth Prajosh