Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Feb 26, 2022

Building Python now requires IEEE 754 (floating point) support.

sys.float_repr_style is now always 'short'.

Remove the _PY_SHORT_FLOAT_REPR macro.

https://bugs.python.org/issue46852

Building Python now requires IEEE 754 (floating point) support.

sys.float_repr_style is now always 'short'.

Remove the _PY_SHORT_FLOAT_REPR macro.
@vstinner
Copy link
Member Author

@mdickinson: Is it ok to require an implementation of the HAVE_PY_SET_53BIT_PRECISION macro if the X87_DOUBLE_ROUNDING macro is defined? I'm not sure about the error message:

// Double rounding is symptomatic of use of extended precision on x86.
// If we're seeing double rounding, and we don't have any mechanism available
// for changing the FPU rounding precision, then don't use Python/dtoa.c.
#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION)
#  error "Building Python requires IEEE 754 support"
#endif

@mdickinson
Copy link
Member

@vstinner The change you're making here is stronger than merely requiring IEEE 754. This change will break CPython on platforms where:

  • The platform does use IEEE 754 floating-point
  • The FPU being used is an Intel x87 or something like it (e.g., think 32-bit Linux)
  • The HAVE_PY_SET_53BIT_PRECISION and associated macros are not defined.

Such platforms have certainly existed historically.

@mdickinson
Copy link
Member

Is it ok to require an implementation of the HAVE_PY_SET_53BIT_PRECISION macro if the X87_DOUBLE_ROUNDING macro is defined?

No, I don't think it's okay, at least not without any warning.

@mdickinson
Copy link
Member

Such platforms have certainly existed historically.

Here's an example report: https://stackoverflow.com/questions/29920294/what-causes-pythons-float-repr-style-to-use-legacy

On an ARM926EJ-S, you don't get the short representation:

@mdickinson
Copy link
Member

@vstinner You've linked this PR to https://bugs.python.org/issue46852, but that issue looks completely different. This PR goes way beyond anything to do with removing float.__setformat__. Please could you fix?

@vstinner
Copy link
Member Author

I misunderstood the relationship between requiring IEEE 754 support and the ability to get short float repr. I started from:

#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \
    !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \
    !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
#  define _PY_SHORT_FLOAT_REPR 0
#endif

And then followed the breadcrumb.

@vstinner
Copy link
Member Author

@vstinner You've linked this PR to https://bugs.python.org/issue46852, but that issue looks completely different. This PR goes way beyond anything to do with removing float.setformat. Please could you fix?

My plan is to remove code which is only needed for platforms not supporting IEEE 754. I wasn't sure if a new issue was needed or not. I hesitated to change https://bugs.python.org/issue46852 title.

I understand that there are platforms which support IEEE 754 but don't support short float repr, because they don't use 64-bit float and lack HAVE_PY_SET_53BIT_PRECISION support.

I just close my PR. Thanks for your review @mdickinson!

@vstinner vstinner closed this Feb 26, 2022
@vstinner vstinner deleted the short_float_repr branch February 26, 2022 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants