Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 680: Note that double precision float is a recommendation not requirement #2278

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions pep-0680.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,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
hukkin marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down