On Fri, Dec 18, 2015 at 11:10 PM, Steven D'Aprano steve@pearwood.info wrote:
On Fri, Dec 18, 2015 at 10:43:24PM -0500, Franklin? Lee wrote:
On Fri, Dec 18, 2015 at 10:38 PM, Steven D'Aprano steve@pearwood.info wrote:
On Fri, Dec 18, 2015 at 05:59:39PM -0500, Franklin? Lee wrote:
I see two options:
- comparison is explicitly NotImplemented. Any code that used it
should've used `is`.
We're still talking about equality between Mapping.values() views, correct?
[...]
First, failing fast. I see this as a silent error waiting to happen.
Franklin, could you please try to be a little bit more explicit about what "it" and "this" is when you describe something? I find it very hard to understand what *specific* thing you are referring to when you refer to it using short-hand.
You say that "this" is a silent error waiting to happen. Does "this" refer to your suggestion that "comparison is explicitly NotImplemented", or something else? I can't tell.
Sorry, bad habit. I see dict().values().__eq__ as an error.
Second, "NotImplemented" allows the other side to try its __eq__.
Okay, that makes better sense. I tought you meant that Mapping.ValuesView *did not implement* an __eq__ method, so that it raised an exception if you tried to compare them:
# What I thought you meant a.values() == b.values() => raises an exception
Now I understand that you mean they should return NotImplemented instead. But in practice, that doesn't actually change the behaviour that much: if both sides return NotImplemented, Python will fall back to the default behaviour, which is identity.
I didn't realize this.
Since explicitly raising NotImplemented would cause it NOT to try the reflected method, I withdraw the suggestion of making the comparison fail in any way that it doesn't already.