-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: ujson better handling of very large and very small numbers, throw ValueError for bad double_precision arg #4042 #4299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…w ValueError for bad double_precision arg pandas-dev#4042
How about for numbers that make full use of double precision? E.g. 1.234567890123456e-40 Also, I trust @njsmith 's opinion over my own on this ... :) |
It seems to work ok
And at least it throws an error for an invalid precision setting now rather than silently capping it at 15. |
I'm a little concerned about the rounding up of 5 to 6, here:
|
That'll be sprintf rounding things which is standard behaviour for it when given a precision. I'm investigating the use of |
Although simplejson has the same rounding behaviour, just to one more decimal place, so I'm inclined to stick with the changes above (i.e. sprintf) now:
|
@Komnomnomnom merge? |
I'm happy with it, and I don't have any other commits in the pipeline. There's probably scope for more improvements, but not in this PR. |
ENH: ujson better handling of very large and very small numbers, throw ValueError for bad double_precision arg #4042
thank you sir! |
closes #4042
This makes ujson handle very big and very small numbers a bit better, it doesn't help with precision but it should at least be able to handle very small and large exponentials now:
I have also modified it to throw a
ValueError
when a bad value is given fordouble_precision
:Tested on Python 2.7 on Arch-64. T'would be great if someone could test this out on windows.