Skip to content

gh-137871: Clarify cmath.nan documentation by linking to math module #137876

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AzizCode92
Copy link

@AzizCode92 AzizCode92 commented Aug 17, 2025

The documentation for cmath.nan is updated to cross-reference the equivalent constants in the math module.

The math module's documentation contains a more thorough explanation of the properties of these special floating-point values, as required by the IEEE 754 standard (e.g., that NaN does not compare equal to itself).


📚 Documentation preview 📚: https://cpython-previews--137876.org.readthedocs.build/en/137876/library/cmath.html#cmath.nan

The documentation for `cmath.nan` and `cmath.inf` is updated to
cross-reference the equivalent constants in the `math` module.

The `math` module's documentation contains a more thorough
explanation of the properties of these special floating-point
values, as required by the IEEE 754 standard (e.g., that NaN
does not compare equal to itself).
@skirpichev skirpichev requested a review from AA-Turner August 17, 2025 12:47
AzizCode92 and others added 2 commits August 17, 2025 15:00
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@skirpichev skirpichev changed the title gh-137871: Clarify cmath.nan/inf documentation by linking to math module gh-137871: Clarify cmath.nan documentation by linking to math module Aug 17, 2025
@skirpichev skirpichev added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 17, 2025
@skirpichev
Copy link
Contributor

@AzizCode92, next time you can combine several suggestions on tab "Files Changed".

@AzizCode92
Copy link
Author

@AzizCode92, next time you can combine several suggestions on tab "Files Changed".

Sure

@StanFromIreland
Copy link
Member

[@skirpichev] Ditto for inf.

Do we not want to do this?

@skirpichev
Copy link
Contributor

Do we not want to do this?

No. Sorry for that suggestion. This just add link with a same info.

Comment on lines 341 to +344
``float('nan')``.

See also :data:`math.nan`.

Copy link
Member

Choose a reason for hiding this comment

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

cmath.nan is more equivalent to math.nan than float('nan') in being a fixed data object, with a fixed id, rather than a function which can return different objects with different ids when called multiple times.

Suggested change
``float('nan')``.
See also :data:`math.nan`.
:data:`math.nan`.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's better. Link just show you same statement of "equivalency". Better just inline it here. In all respect it's "an equivalency", i.e. all nan's in Python are same in sense that we don't have separated signaling/quiet nans and they don't have payload. (Or, in some sense, we don't have simple user interface to this stuff.)

(BTW, I think you suggestion is off by one whitespace.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants