On Wed, Jun 17, 2020 at 3:47 PM Steven D'Aprano <st...@pearwood.info> wrote: > > On Wed, Jun 17, 2020 at 10:58:38AM +1000, Chris Angelico wrote: > > On Wed, Jun 17, 2020 at 10:43 AM 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? > > > > > > > What do you mean? JSON doesn't have a "float" type with IEEE > > semantics. It just has a "Number" type, which is defined syntactically > > but not semantically. It doesn't mandate 53-bit precision, for > > instance, so you can carry large integers between languages that > > support them. > > I never mentioned float type or 53 bit precision. > > In Javascript: > > js> typeof(NaN) > number > js> typeof(Infinity) > number > > Odd as it may seem, NANs and INFs are numbers. And the JSON standard > isn't capable of encoding them. The JSON standard defines "number" in > such a way that even in the language that originated JSON, it can't > represent all numbers. >
That's JavaScript you're looking at, not JSON. The JSON standard never says anything about IEEE floats. You said the words "supported type" and clearly implied IEEE floats, complete with infinity and nan, but that is not what the standard says. The "supported type" in JSON is simply a string of digits, optionally with a decimal point and/or an exponent. That is all. ChrisA _______________________________________________ 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/VR5TJNDG7GNC2BPIQVVUDIOEFCIXOVJR/ Code of Conduct: http://python.org/psf/codeofconduct/