Skip to content

Conversation

@mohsinm-dev
Copy link

@mohsinm-dev mohsinm-dev commented Nov 8, 2025

Summary

Fixes issue #141218 by correcting inaccurate documentation about object comparison.

Problem: The current documentation states "Objects of different types, except different numeric types, never compare equal" which is factually incorrect.

Counter-example:

>>> frozenset([1, 2]) == {1, 2}
True

Solution: Changed to "Objects of different types, unless documented otherwise, never compare equal" to account for all documented exceptions.

Documented exceptions include:

  • Numeric types (int, float, complex) - already mentioned
  • set/frozenset comparisons - documented later in same file
  • dict subclass comparisons (defaultdict, Counter, OrderedDict)

Changes

  • Updated Doc/library/stdtypes.rst line 167
  • Added news entry in Misc/NEWS.d/next/Documentation/

Test plan

  • Documentation builds successfully with make html
  • Verified change maintains consistency with existing specific type documentation
  • Tested that the issue examples work as described
  • Confirmed change is minimal and maintains readability

The fix improves documentation accuracy while maintaining clarity and consistency.


📚 Documentation preview 📚: https://cpython-previews--141221.org.readthedocs.build/

Changed "Objects of different types, except different numeric types, never
compare equal" to "Objects of different types, unless documented otherwise,
never compare equal" to account for documented exceptions like set/frozenset
comparisons.
@python-cla-bot
Copy link

python-cla-bot bot commented Nov 8, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Fix inaccurate documentation about object comparison. Changed "Objects of different
types, except different numeric types, never compare equal" to "Objects of different
types, unless documented otherwise, never compare equal" to account for documented
exceptions like set/frozenset comparisons. No newline at end of file
Copy link
Contributor

@OTheDev OTheDev Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exceptions like set/frozenset comparisons.
exceptions like set/frozenset comparisons.

To fix the lint error

@skirpichev
Copy link
Contributor

I suggest just revert news. Its usually not required for docs changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants