Joao S. O. Bueno wrote:
> yes,  just that it should be called dump_as_float and take either a
> class
> or a tuple-of-classes

I saw kind of symmetry with the `parse_float` which only accepted one class for 
having only one class on the output as well. Besides there are probably not 
many (different) ways how to write a custom type for JSON float in one 
application. But I cannot see any argument for not having a tuple.

> (or maybe just another argument that when set to
> "True" would
> work for any object for which isinstance(obj, numbers.Number) is True)

I cannot verify it right now, but if integer (or big int) are derived from 
`numbers.Number` than it would not work as a distinction for a float. Big int 
is already handled by standard module correctly.

> is not the role of the language or its libraries
> to prevent any way that the JSON encoded string is valid-json. So, maybe
> emitting a warning there, but

>From the other responses I got an impression that ensuring the validity of the 
>output was important part of the standard implementation. But regardless that, 
>here I believe the check with `float(dump_val)` is actually a check to 
>validate the contract with the custom serializer, which seems reasonable, 
>whether it should be an error or a warning I have no idea. I hope Andrew or 
>Paul could comment on that.

> raising TypeError will only make someone intending to encode numbers in
> Hexadecimal in her  custom JSON to pop
> here crying tomorrow.

I am not sure hexadecimal representation is officially recognized as a number i 
JSON and float number in particular, so in that case she will probably be 
encoding it a string already.
_______________________________________________
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/UT2UVSAY7U576ALJWIF7KAJG4TCSQ5KJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to