[issue16535] json encoder unable to handle decimal

Antoine Pitrou report at bugs.python.org
Mon Mar 24 22:31:55 CET 2014


Antoine Pitrou added the comment:

The patch isn't really ok, IMO. It forcibly imports the decimal module and then looks up the type there. The decimal module is a rather large one and it shouldn't get imported if it doesn't get used.

I think it would be better to rely on the __float__ special method, which would also automatically accept other numberish types such as Fraction.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16535>
_______________________________________


More information about the Python-bugs-list mailing list