Keys views are set-like since their entries are unique and :term:hashable. If all values are hashable, so that (key, value) pairs are unique and hashable, then the items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) For set-like views, all of the operations defined for the abstract base class :class:collections.abc.Set are available (for example, ==, <, or ^). While using set operators, set-like views accept any iterable as the other operand, unlike sets which only accept sets as the input.
> {1:2, 3:4}.items() >= {1:2}.items()
True
> {1:[2], 3:4}.items() >= {1:[2]}.items()
True
> set({1:[2], 3:4}.items())
TypeError: unhashable type: 'list'
It seems like this documentation is not accurate. dict.items() does have set operations even when the values are not hashable.
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