-
-
Notifications
You must be signed in to change notification settings - Fork 13
ENH: Support arbitrary-length Python ints in QuadPrecision constructor #213
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
I'd like to give the C code a careful once-over later today. |
Cool, I'll do maybe 2 more PRs today (its a holiday here so xD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't spot any errors in the C code but I have some suggestions to improve code quality. In particular, it's good practice to test error cases if it's reasonable to do so and I spotted some opportunities for a refactor.
| else if (lval == -1 && PyErr_Occurred()) { | ||
| Py_DECREF(py_int); | ||
| Py_DECREF(self); | ||
| return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can test this error case by defining a class with an __index__ implementation that raises.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow this isn't failing it, maybe need more low level of int corruption to trigger this.
Anyways rest are added
|
Thanks @ngoldbaum mostly reviews seem to be connecting to more exhaustive testing, I'll soon add the tests to address them |
|
@ngoldbaum gentle reminder here, if this is GTG and also the #221 |
|
Looks like we had a race condition. I just submitted the review for #221 and was going to look at this next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR is a part of work, where making
numpy_quaddtypecompatible with NumPy's longdouble testsDetails
Use
PyLong_AsLongLongAndOverflowinstead ofPyLong_AsLongLong, and handle the overflow case explicitly by reconstructing theQuadPrecisionobject via string conversion.