| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
This value indicating support the IEC 60559 floating-point standard (the Annex F of C99). If enabled, the float type characteristics matches the IEC 60559 double format and exceptional cases for the math's functions follow to the section F.10 of the C99 standard.
|
I think it would be better if the field was in uppercase but I don't know if we have many other cases like that. |
Sorry, something went wrong.
This will be inconsistent wrt the rest (other field names are also come from macros). |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Co-authored-by: Victor Stinner <vstinner@python.org>
|
I'm thinking if it does make sense to mention this flag in cmath docs. We could say that:
|
Sorry, something went wrong.
|
@picnixz @serhiy-storchaka: What do you think of this change? |
Sorry, something went wrong.
|
I am not sure what is the best place for this constant. What do @mdickinson and @tim-one think about this? Other options are discussed in the issue. |
Sorry, something went wrong.
|
I'm not really comfortable with float_info but I don't really know whether a module-wide constant is better. I would be more comfortable with a new struct, say stdc_info or features_info which contains other feature for the C standard. |
Sorry, something went wrong.
I think, this flag should rather describe conformance with the IEEE 754 / IEC 60559. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@mdickinson and @tim-one didn't reply. Would you be ok with sys.float_info.iec_60559 flag? IMO it's a good fit. |
Sorry, something went wrong.
|
@serhiy-storchaka, see #145633 (comment). It looks like the float.__getformat__() class method often misused in the CPython tests. The sys.float_info.iec_60559 flag is a good replacement for this private interface. The sysconfig module doesn't look as a right place to keep this stuff, just because it's dependency on Python implementation (we don't mention somewhere in docs which variables must be available here and how they should be named). IMO, we only have to decide: where in the sys module put this flag? |
Sorry, something went wrong.
|
Maybe open a DPO thread? |
Sorry, something went wrong.
Reformat also the doc to fit into 80 columns.
|
I decided to merge the change adding sys.float_info.iec_60559 attribute. I completed the PR to mention the addition in What's New in Python 3.15. Since sys.float_info also maps other C float macros, IMO it's a good home to add iec_60559. |
Sorry, something went wrong.
|
Build info on CI runs on this PR:
So iec_60559 is only true on Ubuntu CI. |
Sorry, something went wrong.
|
Yes, it looks adoption of the standard is poor as before. @vstinner, maybe it does make sense to revert this pr. Certainly, this flag can't be used for the support.requires_IEEE_754 decorator - it filters out too much. |
Sorry, something went wrong.
|
I also looked at buildbots. iec_60559=True:
iec_60559=False:
Note: Some buildbots didn't run yet with the new iec_60559 attribute (I restarted the buildbot server this morning, it was stuck for an unknown reason). Some buildbots don't dump test.pythoninfo (ex: Android). |
Sorry, something went wrong.
Why? It remains useful in the platforms where it's true, no?
Well, that's another issue. |
Sorry, something went wrong.
|
I built Python with clang 21.1.8 on my Fedora 43 with glibc 2.42-10: sys.float_info(..., iec_60559=True). That's surprising because https://clang.llvm.org/c_status.html says about "C99 implementation status" that "Clang does not define __STDC_IEC_559__":
/usr/include/stdc-predef.h contains: /* glibc's intent is to support the IEC 559 math functionality, real
and complex. If the GCC (4.9 and later) predefined macros
specifying compiler intent are available, use them to determine
whether the overall intent is to support these features; otherwise,
presume an older compiler has intent to support these features and
define these macros by default. */
#ifdef __GCC_IEC_559
# if __GCC_IEC_559 > 0
# define __STDC_IEC_559__ 1
# define __STDC_IEC_60559_BFP__ 201404L
# endif
#else
# define __STDC_IEC_559__ 1
# define __STDC_IEC_60559_BFP__ 201404L
#endif |
Sorry, something went wrong.
That's essentially linux and glibc with "intent is to support" ("An implementation that defines STDC_IEC_559 shall conform to the specifications in this annex." - this is not about best wishes, right?). The rest looks same as 20+ years ago :(, quite disappointing for me.
Yes, at least we can fill bugreports, when it's enabled and things goes wrong. The cons is that this not useful in the test suite. |
Sorry, something went wrong.
|
I modified Android buildbot to dump also Python build information: sys.float_info(..., iec_60559=False). |
Sorry, something went wrong.
|
And I also modified iOS CI to dump the Python build information: sys.float_info(..., iec_60559=False). |
Sorry, something went wrong.
|
A few more:
So it seems like sys.float_info.iec_60559 is only true (__STDC_IEC_559__ macro is defined) on Linux platforms, using glibc or musl, on many architectures, on any Linux distribution, using GCC or Clang, but not on Android. It's false on all other platforms: Windows, macOS/iOS, WASI/Emscripten, FreeBSD, Solaris. I also tested compiler flags on this C program: #include <stdio.h>
int main()
{
#ifdef __STDC_IEC_559__
printf("__STDC_IEC_559__ defined\n");
#else
printf("NO! __STDC_IEC_559__ is NOT defined\n");
#endif
return 0;
}
So using GCC (15.2.1), __STDC_IEC_559__ is not defined when using -Ofast, whereas Clang (21.1.8) always defines __STDC_IEC_559__ even if -ffast-math is used. |
Sorry, something went wrong.
I think it's come from glibc (from quote above):
|
Sorry, something went wrong.
This reverts commit 68c7fad. It looks like on practice the __STDC_IEC_559__ doesn't indicate conformance to the standard. It can't be used to filter out tests or to give some promises in documentation. See discussion in the reverted PR thread: #138811 (comment)
…8811) This value indicating support the IEC 60559 floating-point standard (the Annex F of C99). If enabled, the float type characteristics matches the IEC 60559 double format and exceptional cases for the math's functions follow to the section F.10 of the C99 standard. Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
…#146501) This reverts commit 68c7fad. It looks like on practice the __STDC_IEC_559__ doesn't indicate conformance to the standard. It can't be used to filter out tests or to give some promises in documentation. See discussion in the reverted PR thread: python#138811 (comment)
…8811) This value indicating support the IEC 60559 floating-point standard (the Annex F of C99). If enabled, the float type characteristics matches the IEC 60559 double format and exceptional cases for the math's functions follow to the section F.10 of the C99 standard. Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
…#146501) This reverts commit 68c7fad. It looks like on practice the __STDC_IEC_559__ doesn't indicate conformance to the standard. It can't be used to filter out tests or to give some promises in documentation. See discussion in the reverted PR thread: python#138811 (comment)
| Back | FazBrowse Home | New Git URL |
This value indicating support the IEC 60559 floating-point standard (specified by the Annex F of C99, for C language). If enabled, the float type characteristics matches the IEC 60559 double format and exceptional cases for the math's functions follow to the section F.10 of the C99 standard.
📚 Documentation preview 📚: https://cpython-previews--138811.org.readthedocs.build/
https://cpython-previews--138811.org.readthedocs.build/en/138811/library/sys.html#sys.float_info
https://cpython-previews--138811.org.readthedocs.build/en/138811/library/math.html#math.nan