On Wed, Aug 14, 2019 at 3:12 AM Andrew Barnert via Python-ideas email@example.com wrote:
On Aug 13, 2019, at 01:04, Richard Musil firstname.lastname@example.org wrote:
Concerning the custom separators, and why the implementation supports them, I believe it is not actually about the separators themselves, but the whitespaces around them. When you generate JSON with an indentation, you probably also want some spacing after double colon or comma so it looks "pretty".
Ignoring safety, it might be a bit simpler to use, but probably a tiny bit slower...
Something to bear in mind is that the JSON module is often called upon to deal with gobs of data. Just last night I was showcasing a particular script that has to load a 200MB JSON file mapping Twitch emote names to their emote IDs, and it takes a solid 5-6 seconds to parse it. A small slowdown or speedup can have significant impact on real-world programs.
That's one of the reasons that a simple solution of "make JSONEncoder respect decimal.Decimal" was rejected - it would require that the json module import decimal, which is extremely costly. Having a __json__ protocol would be less costly, but would still have a cost, so this needs to be factored in.