-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
dict
items views have set like operations even when the values are not hashable.
#111622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
My guess is the same as in 'Blcknight's answer: it was realized that items is read only, making hash((key,value)) = hash(key) is sufficient, making the caveat in the doc unnecessary. To be sure, someone should check that the items for the example dict works for all of the supported operations. And check the dict items code and the git blame history of revisions of that code. |
Not all set operations actually work, for example |
Perhaps replace with second sentence with:
|
They are set-like even when some values are not hashable, but work even better when all are.
#112051 is mostly Raymond's suggestion. |
They are set-like even when some values are not hashable, but work even better when all are.
They are set-like even when some values are not hashable, but work even better when all are. (cherry picked from commit e31d65e) Co-authored-by: Terry Jan Reedy <[email protected]>
They are set-like even when some values are not hashable, but work even better when all are. (cherry picked from commit e31d65e) Co-authored-by: Terry Jan Reedy <[email protected]>
3.11 backport failed (conflict) |
They are set-like even when some values are not hashable, but work even better when all are.
They are set-like even when some values are not hashable, but work even better when all are.
Documentation
It seems like this documentation is not accurate.
dict.items()
does have set operations even when the values are not hashable.See also: https://stackoverflow.com/questions/77399592/set-like-behaviour-of-dict-items-for-non-hashable-values
Linked PRs
The text was updated successfully, but these errors were encountered: