This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author roippi
Recipients gvanrossum, rhettinger, roippi, serhiy.storchaka
Date 2014-08-15.17:26:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408123600.84.0.297085292262.issue22192@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-08-15 17:26:40roippisetrecipients: + roippi, gvanrossum, rhettinger, serhiy.storchaka
2014-08-15 17:26:40roippisetmessageid: <1408123600.84.0.297085292262.issue22192@psf.upfronthosting.co.za>
2014-08-15 17:26:40roippilinkissue22192 messages
2014-08-15 17:26:40roippicreate