The hash was an argument for having the means to preserve the precision (or 
representation) of the float (in its textual form) over decode-encode. The 
example was just chosen because I had experienced it in my project.

But I never said that I need the underlying binary representation to be bit to 
bit accurate over any JSON decoder-encoder. I am perfectly aware of float 
binary representation limitation and already provided anecdotal evidence of 
different results from two different encoders.

The points was that I could have this bit to bit accuracy implemented with the 
custom type and its encoder/decoder (if the default one did not support), if 
only standard module supported it. The custom type could be decimal.Decimal and 
the support would involve the decoding (which is already implemented) and 
encoding which, at the moment, is not possible to implement.

So to sum up, I am asking for the support in the JSON module, so I can 
implement bit to bit (or let's say byte to byte) accuracy with a custom type, 
if needed. Not that the JSON module has to have it. I do not know if the 
generic solution (for an arbitrary type) is really needed and I hoped you might 
be able to judge that better. In my particular case it only concerns float.

I can use simplejson and it solves my problem. It just seemed strange that the 
standard module did not support it, in particular that it supported it only 
half-way. I was coming here to get an idea, why it might be the case (if there 
was any case in the first place) and to gather other opinions.
_______________________________________________
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/DROHYKXST7O3JZBB3KKAZNRXGHUFBOEE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to