[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-25 Thread STINNER Victor
STINNER Victor added the comment: PEP 7 has been updated, I close the issue. -- status: open -> closed ___ Python tracker ___ ___

[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread Petr Viktorin
Petr Viktorin added the comment: > IMO this PEP is outdated for a long time. It is not. Even if it is, it should be marked as such, and that is not a decision that should be done in this issue. Please, don't break the rules because you think they're outdated. > Well, if you ask me, I would

[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: > Well, if you ask me, I would simply require a C99 compiler. That's all :-) Done in https://github.com/python/peps/pull/2309 -- ___ Python tracker

[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: > Adding new C99 features needs a change in PEP 7 > (https://www.python.org/dev/peps/pep-0007/#c-dialect) IMO this PEP is outdated for a long time. C99 standard is wide. Do we have to explicitly list every single function, macro or constant used by Python?

[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-07 Thread Petr Viktorin
Petr Viktorin added the comment: Adding new C99 features needs a change in PEP 7 (https://www.python.org/dev/peps/pep-0007/#c-dialect) -- nosy: +petr.viktorin status: closed -> open ___ Python tracker

[issue46640] Python can now use the C99 NAN constant or __builtin_nan()

2022-02-06 Thread STINNER Victor
STINNER Victor added the comment: I merged my change, thanks for the reviews. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed title: Python can now use the C99 NAN constant -> Python can now use the C99 NAN constant or __builtin_nan()

[issue46640] Python can now use the C99 NAN constant

2022-02-06 Thread STINNER Victor
STINNER Victor added the comment: New changeset 54842e4311bb0e34012d1984b42eab41eeeaea6a by Victor Stinner in branch 'main': bpo-46640: Py_NAN now uses the C99 NAN constant (GH-31134) https://github.com/python/cpython/commit/54842e4311bb0e34012d1984b42eab41eeeaea6a --

[issue46640] Python can now use the C99 NAN constant

2022-02-05 Thread Mark Dickinson
Mark Dickinson added the comment: > If a platform doesn't implement NaN, it should define the Py_NO_NAN macro Ah. In that case your PR description (and the PR news entry) is misleading: > Building Python now requires a C99 header file providing the > NAN constant. Please could you update

[issue46640] Python can now use the C99 NAN constant

2022-02-05 Thread STINNER Victor
STINNER Victor added the comment: > The big blocker here is that a platform that fully supports C99 might not > define the "NAN" macro. I don't think we can require that NAN be defined in > order for Python to build (which is what the PR currently does, if I'm > understanding it correctly).

[issue46640] Python can now use the C99 NAN constant

2022-02-05 Thread Mark Dickinson
Mark Dickinson added the comment: The big blocker here is that a platform that fully supports C99 might not define the "NAN" macro. I don't think we can require that NAN be defined in order for Python to build (which is what the PR currently does, if I'm understanding it correctly). Python

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: Using clang -E, I see that clang also replaces NAN with: __builtin_nanf (""). -- ___ Python tracker ___

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: > see attached script: test_nan_bits.py test_nan_bits.py says "True" for Python built with "clang -O3" and with "clang -O0". -- ___ Python tracker

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: Python/dtoa.c uses: /* Standard NaN used by _Py_dg_stdnan. */ #define NAN_WORD0 0x7ff8 #define NAN_WORD1 0 /* Return a 'standard' NaN value. There are exactly two quiet NaNs that don't arise by 'quieting' signaling NaNs (see IEEE 754-2008,

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: Manual test to check if m_nan(), _Py_dg_stdnan(0) and Py_NAN are exactly the same number (same bits): $ ./python >>> import math, struct >>> m_nan=math.nan; Py_NAN=math.atan2(m_nan, 1.0) >>> Py_NAN is m_nan False >>> struct.pack('d', m_nan) ==

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: > mathmodule.c and cmathmodule.c m_nan() still use _Py_dg_stdnan() by default > (if PY_NO_SHORT_FLOAT_REPR is not defined). These functions are only use to create the following constants: * math.nan * cmath.nan * cmath.nanj --

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: The Py_NAN has a special implementation for the ICC compiler, if __INTEL_COMPILER and ICC_NAN_STRICT macros are defined, in bpo-21167: --- commit edbc28ce81f46d042f9d5ddf9c5bc8cecebc715a Author: R David Murray Date: Thu Aug 13 09:58:07 2015 -0400

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +29313 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31134 ___ Python tracker ___

[issue46640] Python can now use the C99 NAN constant

2022-02-04 Thread STINNER Victor
New submission from STINNER Victor : While debugging a GCC regression (*) on "HUGE_VAL * 0" used by Py_NAN macro, I noticed that Python can now C99 "NAN" constant. (*) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104389 In bpo-45440, I already removed legacy code for pre-C99 support and old