Skip to content

Commit e31d65e

Browse files
authored
gh-111622: Fix doc for items views (#112051)
They are set-like even when some values are not hashable, but work even better when all are.
1 parent 31ad7e0 commit e31d65e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Doc/library/stdtypes.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -4755,14 +4755,17 @@ support membership tests:
47554755

47564756
.. versionadded:: 3.10
47574757

4758-
Keys views are set-like since their entries are unique and :term:`hashable`. If all
4759-
values are hashable, so that ``(key, value)`` pairs are unique and hashable,
4760-
then the items view is also set-like. (Values views are not treated as set-like
4758+
Keys views are set-like since their entries are unique and :term:`hashable`.
4759+
Items views also have set-like operations since the (key, value) pairs
4760+
are unique and the keys are hashable.
4761+
If all values in an items view are hashable as well,
4762+
then the items view can interoperate with other sets.
4763+
(Values views are not treated as set-like
47614764
since the entries are generally not unique.) For set-like views, all of the
47624765
operations defined for the abstract base class :class:`collections.abc.Set` are
47634766
available (for example, ``==``, ``<``, or ``^``). While using set operators,
4764-
set-like views accept any iterable as the other operand, unlike sets which only
4765-
accept sets as the input.
4767+
set-like views accept any iterable as the other operand,
4768+
unlike sets which only accept sets as the input.
47664769

47674770
An example of dictionary view usage::
47684771

0 commit comments

Comments
 (0)