[issue22192] dict_values objects are hashable

2014-09-05 Thread Ben Roberts
Ben Roberts added the comment: Going to close this down - implementing rich comparisons for values() does feel like the correct solution... but I don't think it's possible to implement __eq__ in better than nlogn time (and possibly space). So nothing can realistically be done, yeah. -

[issue22192] dict_values objects are hashable

2014-08-15 Thread Guido van Rossum
Guido van Rossum added the comment: Oh. Yeah. Then I think there's nothing to do. -- ___ Python tracker ___ ___ Python-bugs-list maili

[issue22192] dict_values objects are hashable

2014-08-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > I think just a a.keys() == set(a.keys()), a.values() should be == > set(a.values()). Every element of a.keys() is hashable and unique. a.values() can contain non- hashable repeated elements. -- ___ Python tracker

[issue22192] dict_values objects are hashable

2014-08-15 Thread Guido van Rossum
Guido van Rossum added the comment: It's clear that dict.values() shouldn't be hashable -- using the identity is plain wrong here. But shouldn't the fix be to implement rich comparisons for dict.values()? I think just a a.keys() == set(a.keys()), a.values() should be == set(a.values()). Let'

[issue22192] dict_values objects are hashable

2014-08-15 Thread Ben Roberts
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

[issue22192] dict_values objects are hashable

2014-08-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is a question. What builtin types should be hashable? In particular, should be hashable iterators, generators? -- ___ Python tracker __

[issue22192] dict_values objects are hashable

2014-08-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: Do you want to submit a patch and tests? Also take a look at the collections.abc MappingViews. -- assignee: -> rhettinger nosy: +gvanrossum priority: normal -> low stage: -> needs patch ___ Python tracker

[issue22192] dict_values objects are hashable

2014-08-13 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka versions: +Python 3.5 ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue22192] dict_values objects are hashable

2014-08-13 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue22192] dict_values objects are hashable

2014-08-13 Thread Ben Roberts
New submission from Ben Roberts: 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: