PEP 680: Note that double precision float is a recommendation not requirement (GH-2278)

This commit is contained in:
Taneli Hukkinen 2022-01-27 12:27:05 +02:00 committed by GitHub
parent 579627054d
commit e647fcedbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -333,14 +333,17 @@ support could be added later in a backward-compatible way.
Removing support for ``parse_float`` in ``tomllib.load[s]``
-----------------------------------------------------------
This option is not strictly necessary, since TOML floats are "IEEE 754 binary64
values", which is equivalent to a Python ``float`` on most architectures.
However, parsing floats differently, such as to ``decimal.Decimal``, allows
users extra precision beyond that promised by the TOML format. In the
author of ``tomli``'s experience, this is particularly useful in scientific and
financial applications. This is also useful for other cases that need greater
precision, or where end-users include non-developers who may not be aware of
the limits of binary64 floats.
This option is not strictly necessary, since TOML floats should be implemented
as "IEEE 754 binary64 values", which is equivalent to a Python ``float`` on most
architectures.
The TOML specification uses the word "SHOULD", however, implying a
recommendation that can be ignored for valid reasons. Parsing floats
differently, such as to ``decimal.Decimal``, allows users extra precision beyond
that promised by the TOML format. In the author of ``tomli``'s experience, this
is particularly useful in scientific and financial applications. This is also
useful for other cases that need greater precision, or where end-users include
non-developers who may not be aware of the limits of binary64 floats.
There are also niche architectures where the Python ``float`` is not a IEEE 754
binary64 value. The ``parse_float`` argument allows users to achieve correct