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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/library/cmath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ Constants
A floating-point "not a number" (NaN) value. Equivalent to
``float('nan')``.

See also :data:`math.nan`.

Comment on lines 341 to +344
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.)

.. versionadded:: 3.6


Expand Down
Loading