-
Notifications
You must be signed in to change notification settings - Fork 52
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
For comparison functions, use subclass check, or identity check? #51
Comments
Note that
|
Actually, that's not the whole story. In
|
In https://mail.python.org/pipermail/python-dev/2017-November/150883.html, @gvanrossum suggested matching the fields as well as their values. This means that a class and a subclass that doesn't add any fields could be compared, but if a subclass adds fields it will not be comparable. This comes down to:
You can just compare I think this is a good solution, and provides the functionality that we're looking for. I'll come up with a PR shortly. |
…ared as long as no fields have been added.
@hynek: Can you comment on why
That is, why the exact test for type matching on eq and ne, but the isinstance test on the others? Thanks. |
I’m gonna say it’s an oversight when I made eq stricter. I seem to remember, that someone told me, that it should be strict, but I don’t really remember because it’s 2+ years ago. 🤔 |
That's helpful, thanks. Given that, I propose that we leave the code with a strict |
From the Abstract in the PEP, the comparison functions are given as:
There's been discussion on whether this should be a subclass check, or an exact match. I plan on looking in to this and addressing it before the next PEP version. This is a placeholder to remind me, and for discussion.
The text was updated successfully, but these errors were encountered: