Skip to content

Conversation

@AzizCode92
Copy link
Contributor

@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
Contributor 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.)

@AzizCode92
Copy link
Contributor Author

@terryjreedy Is there anything missing I should do here to merge this PR?

Signed-off-by: AzizCode92 <azizbenothman76@gmail.com>
@hugovk hugovk merged commit 025b403 into python:main Oct 14, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Oct 14, 2025
@miss-islington-app
Copy link

Thanks @AzizCode92 for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 14, 2025
…odule (pythonGH-137876)

(cherry picked from commit 025b403)

Co-authored-by: Aziz <azizbenothman76@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 14, 2025
…odule (pythonGH-137876)

(cherry picked from commit 025b403)

Co-authored-by: Aziz <azizbenothman76@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Oct 14, 2025

GH-140095 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Oct 14, 2025
@bedevere-app
Copy link

bedevere-app bot commented Oct 14, 2025

GH-140096 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 14, 2025
hugovk pushed a commit that referenced this pull request Oct 14, 2025
…module (GH-137876) (#140095)

Co-authored-by: Aziz <azizbenothman76@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
hugovk pushed a commit that referenced this pull request Oct 14, 2025
…module (GH-137876) (#140096)

Co-authored-by: Aziz <azizbenothman76@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants