-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
This is a follow-up of the #91073. Proposal was briefly discussed in the referenced issue.
Now support for IEEE floating-point formats is a requirement and the configure script will fail, if it can't detect it. The only exception is some ARM platforms (this come from b08a53a):
Lines 6172 to 6180 in 149c465
| [*arm*], [# Some ARM platforms use a mixed-endian representation for | |
| # doubles. While Python doesn't currently have full support | |
| # for these platforms (see e.g., issue 1762561), we can at | |
| # least make sure that float <-> string conversions work. | |
| # FLOAT_WORDS_BIGENDIAN doesn't actually detect this case, | |
| # but if it's not big or little, then it must be this? | |
| AC_DEFINE([DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754], [1], | |
| [Define if C doubles are 64-bit IEEE 754 binary format, | |
| stored in ARM mixed-endian order (byte order 45670123)])], |
This is only case, when "unknown_format" code patch now could be triggered (BTW, we could detect this format in runtime and switch to yet another "just copy bytes" path). Should we keep this for an unsupported platform? IIRIC, such chips aren't supported even in Debian.
With "unknown_format" we also could drop code to detect endianness in runtime. I'm not sure about float.__getformat__ function. It's docstring says:
>>> help(float.__getformat__)
Help on built-in function __getformat__:
__getformat__(typestr, /) class method of builtins.float
You probably don't want to use this function.
typestr
Must be 'double' or 'float'.
It exists mainly to be used in Python's test suite.
This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
little-endian' best describes the format of floating-point numbers used by the
C type named by typestr.
Probably, it could be treated as private and we should remove it in favor of using configure macros in tests. (__set_format__() method was removed without prior deprecation in 5ab745f). Edit: we could also leave this also as-is for alternative Python implementations, using CPython tests.