> I don't think anyone else has come up with, any
> examples other than Decimal that require this "raw" encoding.
It's possible that someone could have their own custom numeric
type that they want to encode as a JSON number. But if the base
code is enhanced to understand Decimal, that could be achieved
using the existing mechanism for returning an alternative
object to be encoded -- just convert your type to an equivalent
Decimal and return that.
Exactly -- what I realized is that the JSON number is the exact same "data model" as the Python Decimal type. So being able to encode Decimal (and int) allows you to encode ANY valid JSON number.
Which is why I think we don't need to allow the user to be able to customize encoding of numbers (or anything else).
But the current float encoding does not fully support JSON numbers, so we do have a limitation that could/should be addressed.
Python-ideas mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com
Message archived at https://firstname.lastname@example.org/message/M2LT53UY5ZWM7QQGD5XCRWRCV3KCL5X7/
Code of Conduct: http://python.org/psf/codeofconduct/
Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython