Support non-'decimal.Decimal' output
Bug #320555 reported by
alecf
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
jsonlib |
Fix Released
|
Wishlist
|
John Millikin |
Bug Description
Since decimal.Decimal numbers can't be compared directly with python floats, it would be really nice if jsonlib could produce regular floats. I realize there's some lack of accuracy because python floats are kinda funky, but for my application, floats make way more sense..
I'm attaching a patch that adds 'use_float=False' as a default parameter to load/read
To post a comment you must log in.
I would prefer not to add such an option, for two reasons:
* Floating-point inaccuracy causes silent data loss. 99999]'
* Round-tripping with floats can change values: write(read('[1.4]', use_float=True)) -> '[1.39999999999
Are these drawbacks acceptable to you?
In addition, please note that jsonlib was developed before Python had a standardized JSON library. Since then, simplejson[1] has been adopted into the standard library for 2.6 and 3.0. If possible, it would be best to use a library that will be more familiar to potential maintainers of your code. I will continue to maintain jsonlib, but it is unlikely to see major further development.
[1] http:// pypi.python. org/pypi/ simplejson/