-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
gh-113746: Fix set
and frozenset
documents
#130822
Conversation
Divided the class description into a part about sets and a part about frozensets. Also, cleaned up the explanation of the comparison method. Fixed pythongh-113746.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced by this. Isn't there a way to not generate a link for frozenset.update
actually? (we can probably hotfix it with a custom extension though)
Doc/library/stdtypes.rst
Outdated
.. method:: set == other | ||
|
||
Test whether every element of each set is contained in the other, that is, | ||
``set <= other and set >= other``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All objects implement ==
so it's redundant here IMO. In addition, we explain the differences with set == frozenset as well.
Doc/library/stdtypes.rst
Outdated
Both :class:`set` and :class:`frozenset` support set to set comparisons. Two | ||
sets are equal if and only if every element of each set is contained in the | ||
other (each is a subset of the other). A set is less than another set if and | ||
only if the first set is a proper subset of the second set (is a subset, but | ||
is not equal). A set is greater than another set if and only if the first set | ||
is a proper superset of the second set (is a superset, but is not equal). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this one.
Doc/library/stdtypes.rst
Outdated
x not in s | ||
isdisjoint(other) | ||
issubset(other) | ||
set == other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this one.
|
||
Instances of :class:`frozenset` provide the following :class:`set` operations: | ||
|
||
.. method:: len(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would render quite ugly IMO. If users use a link to frozenset.isdisjoint
in their Sphinx project, then it will go there and then the user wouldn't have any proper description.
I agree. The actual docs are much better as they are now. There is no redundancy and there docs are very clear about that operations are available for sets that do not apply to frozensets. If anything needs to be "fixed" it is the indexing. The docs themselves are fine. Marking this as closed. The solution to #113746 needs to be targeted at indexing rather than this indirect solution that makes the long stable documentation worse. Thanks for the PR but I would rather live with the minor indexing buglet (or have it fixed in some other way) than to damage the set/frozenset documentation which has served users well for two decades. |
Divided the class description into a part about sets and a part about frozensets. Also, cleaned up the explanation of the comparison method.
Fixed gh-113746.
📚 Documentation preview 📚: https://cpython-previews--130822.org.readthedocs.build/