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

Optimized abs should be nogil-safe #2746

QuLogic opened this Issue Dec 6, 2018 · 1 comment


None yet
2 participants

QuLogic commented Dec 6, 2018

From the following:

cdef double foo(double x):
    return abs(x)

cdef int bar(int x):
    return abs(x)

the resulting C/C++ code calls fabs/abs thanks to #1255. If you add nogil on these functions, then Cython will complain with:

    return abs(x)
test_abs.pyx:2:14: Calling gil-requiring function not allowed without gil

Because of #1837, I'm not sure about bar, but at least foo should not require the GIL.


This comment has been minimized.


scoder commented Dec 6, 2018

True. It's probably as easy as adding nogil to the declaration of the C functions in PR welcome. Tests should go into tests/run/builtin_abs.pyx.

@QuLogic QuLogic referenced a pull request that will close this issue Dec 7, 2018


Mark optimized abs as being nogil-safe. #2748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment