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
Fix limited API __Pyx_PyObject_ToDouble #5888
Conversation
This fixes compilation of ExprNodes.py and Nodes.py and thus allows all Cython to be compiled with compile-more. (When combined with other limited API PRs)
Cython/Utility/Optimize.c
Outdated
#if CYTHON_ASSUME_SAFE_MACROS | ||
double value = PyFloat_AS_DOUBLE(float_value); | ||
#else | ||
double value = PyFloat_AsDouble(float_value); | ||
#endif |
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.
We do this all over, so let's add a __Pyx_PyFloat_AS_DOUBLE()
macro for this. That also avoids the need for a second special case in the __Pyx_PyObject_AsDouble()
macro (which isn't as efficient as it could be since it doesn't dispatch to PyLong_AsDouble()
directly (or even indirectly)).
Also, we should decide whether the right guard is "Limited API" or "safe macros". I don't think there is anything unsafe about calling PyFloat_AS_DOUBLE()
on a known Python float
object, so I vote for "Limited API" as a special case.
Co-authored-by: scoder <stefan_ml@behnel.de>
I think we generally use an upper case Pyx for utility function names (and macros). Why did you lower case it?
|
…limited-api-obj-to-double
Because that's how what two functions it was next to were. I've upper-cased them all now though |
This fixes compilation of ExprNodes.py and Nodes.py and thus allows all Cython to be compiled with compile-more. (When combined with other limited API PRs)