On Aug 9, 2019, at 17:44, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > > Since Python's Decimal preserves all the information in the JSON > representation of a float (including trailing zeroes!), anything > else you might want can be achieved by pre/postprocessing the > decoded data structure. > > It's just occurred to me that this isn't quite true, since > Decimal doesn't preserve *leading* zeroes.
That one isn’t a problem, because JSON doesn’t allow leading zeroes. If you want to use 00.012 vs. 0.012 to say something meaningful about your precision, you’d have to encode that meaning in JSON as something like 0.0012E1 vs. 0.012E0. Of course Decimal will throw away _that_ distinction, but only for the same reason it throws away all of the distinctions between 0.012E0 vs. 0.012 vs 1.2E-2 vs. 1.2e-2 and so on, so you’re only hitting the everyday problem that Decimal can’t solve for anyone; there’s no additional problem that Decimal can’t solve here that’s only faced by your weird app. > But an application > that cared about that would be pretty weird. So I think a > "use decimal" option would cover the vast majority of use > cases. _______________________________________________ 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/Y2BPGI5QBIOYWOV42OD73AQZIDYD6INX/ Code of Conduct: http://python.org/psf/codeofconduct/