Message225287
In python 3.4 these result in a TypeError:
hash({}.keys())
hash({}.items())
But this succeeds:
hash({}.values())
The 2.7 backports of these - viewkeys, viewitems, and viewvalues respectively - behave equivalently.
See more discussion on StackOverflow: http://stackoverflow.com/questions/25293912/why-are-some-dict-views-hashable
The cause appears to be that key and item views implement rich comparisons, whereas values views do not. Therefore dict_view objects use the default id()-based __hash__ implementation.
Possible fix: explicitly set tp_hash to PyObject_HashNotImplemented for PyDictValues_Type - and perhaps for the other two view types as well, for symmetry. |
|
Date |
User |
Action |
Args |
2014-08-13 20:52:43 | roippi | set | recipients:
+ roippi |
2014-08-13 20:52:43 | roippi | set | messageid: <1407963163.14.0.392361410258.issue22192@psf.upfronthosting.co.za> |
2014-08-13 20:52:43 | roippi | link | issue22192 messages |
2014-08-13 20:52:42 | roippi | create | |
|