Steven D'Aprano writes: > Under what circumstances would you expect two unordered collections of > values: > > {1, 2, 3, 1, 1, 1} > {1, 2, 3, 2, 2, 2} > > to compare equal?
As you've pointed out yourself, I believe, here we are not interested in generic unordered collections. We have views into a dictionary. A dictionary is one way to implement a function, and it's often interesting to know what the image of a function is. I would guess this is one reason why set(d.view()) came up early in the discussion. I hardly think that the range of values in a dict is something that Python programmers would need a PhD to understand, at least not if you present it as "set(d.values())", and optionally "but works if values aren't hashable". I'm -1 on any of the possibilities proposed to be anointed as "==" for dict.values without data on how often they are used in practice, and how often each is used in inner loops. All are easy to spell since dict.values is iterable (if you accept the restriction for set that all dict values be hashable). I would argue that if anything is to be implemented in built ins, it should be the set comparison, since that is the only one that doesn't have a simple spelling for generic dicts. (That doesn't mean I think it should be "==".) >> No, I don't. Do you think the proposed behavior (extending >> equality to views of the same dict, and only that) is *useful*? > It's *less wrong* than the current behaviour i.e. it gets the > comparison correct more often, even if it too sometimes returns > False for values which people would expect to compare equal. I already knew you cared that the minute hand of a stopped clock is right 24 times a day. I don't, and that's not what I asked. Steve _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NX2FFQ6Y5DCI7EQMRXN7TXQ7V5VNK2YG/