PEP 680: "tomllib" Support for parsing TOML in the Standard Library

The TOML 1.0.0 spec says

Floats should be implemented as IEEE 754 binary64 values.

Note that it’s “should” rather than “must” - arguably consumers can choose whatever representation they want. This is similar to JSON, which doesn’t state what representation consumers should use for numbers, but suggests binary64.

The stdlib json library has a parse_float argument, which works exactly the same as the one in tomli. I feel that consistency, combined with the fact that the TOML spec says “should” rather than “must”, supports having the tomli parse_float argument in the stdlib version. (Even though I doubt that I’ll ever personally use it in real code).

7 Likes