Ben Roberts added the comment: I have a patch with tests for this (running the test suite now) but I am increasingly unsure if python isn't doing the right thing already.
Intuitively, it "feels" wrong (to me) to allow a dict_values view to be hashable since the mapping onto which it provides a view is certainly mutable. And mutable things shouldn't be hashable, everyone knows that. However the dict_values object /itself/ doesn't violate the contract of hashability - its hash (which just uses its id()) doesn't change across its lifetime, and some_values_view == foo will only be true iff foo is some_values_view whereas e.g. some_keys_view == some_other_keys_view CAN change across the lifetime of those objects - so the asymmetry here does make sense. It is taking me a while to wrap my brain around this because I often think in terms of "mutable/immutable" but the only thing that's important is the hashability contract, which is not currently violated by dict_values objects. I'm certainly willing to be talked out of my change of opinion here :-), my intuition hasn't fully caught up with my logic. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22192> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com