On Tue, Jun 16, 2020, 8:42 PM Steven D'Aprano <st...@pearwood.info> wrote:

> Please forgive the stupid question, but given that the JSON standard is so
> obviously broken (being unable to serialise valid values from a supported
> type, what on earth were they thinking???), wouldn't all this time and
> energy be better aimed at fixing the standard rather than making Python's
> JSON encoder broken by default?
>

I do not support changing the default in the Python library.

However, I do want to note that JSON is not "broken." The data that gets
represented in JSON may have the type "Number" (RFC 7159). That is, there
is no concept of IEEE-754 floating point, or integer, or Decimal, etc.
There is simply the type "Number" that a particular programming language
may approximate in one of its available types.

The type Number has no specific semantics, only a grammar for what
sequences of characters qualify. There is a large intersection with the
things representable in IEEE-754, but it's neither a subset not superset of
that. From the RFC:

A JSON number such as 1E400 or 3.141592653589793238462643383279

may indicate potential interoperability problems, since it

suggests that the software that created it expects receiving

software to have greater capabilities for numeric magnitude

and precision than is widely available.



On the other side, strings like -inf, Infinity, or NaN are not matched by
the grammar.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OAUGLXBVRRG5FA4KYC63G5AYMBZML25O/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to