Skip to content

Commit 18b88fe

Browse files
[3.12] gh-111622: Fix doc for items views (GH-112051) (#112052)
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 <tjreedy@udel.edu>
1 parent d34650e commit 18b88fe

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Doc/library/stdtypes.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,14 +4752,17 @@ support membership tests:
47524752

47534753
.. versionadded:: 3.10
47544754

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

47644767
An example of dictionary view usage::
47654768

0 commit comments

Comments
 (0)