◐ Shell
clean mode source ↗

gh-104263: Rely on Py_NAN and introduce Py_INFINITY by seberg · Pull Request #104202 · python/cpython

It seems to me code all around relies on both being correct anyway.
The actual value for Py_NAN is subtly incorrect on MIPS (depending
on settings) or at least nonstandard, which seems to confuse some
builtin functions.
(Probably it is signalling, but NumPy saw this with fmin, which probably
should also ignore signalling NaNs, see also numpy/numpy#23158).

The guards about `_PY_SHORT_FLOAT_REPR` making sense are relatively
unrelated to NAN and INF being available.

Nevertheless, I currently hide the Py_NAN definition if that is not
set, since I am not sure what good alternative there is to be certain
that Py_NAN is well defined.
OTOH, I do suspect there is no platform where it is not and it should
probably be changed?!

@sunmy2019 sunmy2019 changed the title MAINT: Rely on Py_NAN and Py_HUGE_VAL being correctly defined gh-104263: MAINT: Rely on Py_NAN and Py_HUGE_VAL being correctly defined

May 7, 2023
We can rely on both as Python now forces IEEE compliance and C99 so
that both should always be well defined and there is no need for
`math.nan` not being defined.

@seberg seberg changed the title gh-104263: MAINT: Rely on Py_NAN and Py_HUGE_VAL being correctly defined MAINT: Rely on Py_NAN and introduce Py_INFINITY

May 7, 2023

@seberg seberg changed the title MAINT: Rely on Py_NAN and introduce Py_INFINITY gh-104263: Rely on Py_NAN and introduce Py_INFINITY

May 7, 2023

mdickinson

@seberg

seberg

@mdickinson

@seberg

seberg

mdickinson

@seberg seberg deleted the maint-double-nan branch

May 10, 2023 16:45

carljm added a commit to carljm/cpython that referenced this pull request

May 10, 2023

carljm added a commit to carljm/cpython that referenced this pull request

May 11, 2023

This was referenced

Jun 4, 2024