Message225353
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. |
|
Date |
User |
Action |
Args |
2014-08-15 17:26:40 | roippi | set | recipients:
+ roippi, gvanrossum, rhettinger, serhiy.storchaka |
2014-08-15 17:26:40 | roippi | set | messageid: <1408123600.84.0.297085292262.issue22192@psf.upfronthosting.co.za> |
2014-08-15 17:26:40 | roippi | link | issue22192 messages |
2014-08-15 17:26:40 | roippi | create | |
|