On Aug 8, 2019, at 10:33, Richard Musil <risa20...@gmail.com> wrote: > > I also did not want to discuss the design decisions about having JSON > unreliable for the hash calculation. In my app, I know I am only dealing with > integers, floats and strings (and arrays and maps), all withing the range of > a standard binary representation (i.e. nothing fancy) and while I agree that > in general, there are many unclear "corner cases" in JSON, I decided that > hashing the (normalized) textual representation was best I could do.
You don’t seem to get that is not obscure “corner cases” that’s the issue, it’s the basic design of JSON. It is not a design goal that different implementations (or even different runs of the same implementation), will produce the same output for equal values. The fact that you’re only dealing with integers, floats, strings, arrays, and maps doesn’t make any difference. The only other values in JSON are the three singletons true/false/null, and all of the variable-formatting issues are with the types you’re using, and with “standard values” for those types (for any definition of “standard” that you can think of, unless you think 1E6 or a string with non-ASCII characters or -0.0 or any array or map at all are outside the “standard” range). So you’re arguing that you’re only affected by 100% of the problems, and therefore you don’t have to think about them. Trying to get two different JSON libraries to always emit exactly the same string for all possible inputs is a mug’s game. You fix one difference, and you’re just going to run into a different one later. If your goal is to not change the hash when the values are unchanged, just compare the dicts or keep track of a dirty flag or whatever and don’t rewrite the file when the values are unchanged. _______________________________________________ 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/YLRA3FWUPN6FLCX26SGQNNDMX7LADLIP/ Code of Conduct: http://python.org/psf/codeofconduct/