Cython 3 has come out and there are a lot of big changes. I've run into a couple gotchas so far and we'll need to be careful. I think we should make sure to force cython>=3 in the pyproject.toml. Issues I've run into so far:
DEF/constants are being deprecated. See https://github.com/cython/cython/issues/4310. However, I haven't found good replacements for some of the use cases so I'm not sure this is the first thing we tackle.
cdef functions now default to exceptions being possible (as if you had done except -1 or similar). For many cases of the code I write this isn't what I want. On nogil functions this is extra bad because it adds a GIL acquire and release to check the error state. The fix is to do noexcept nogil: at the end of the function declaration. Checking the HTML output of cython -a some_module.pyx makes it pretty clear since our nogil functions shouldn't have any yellow (non-C code).
We can and should probably drop the old numpy API by defining in setup.py:
Cython 3 has come out and there are a lot of big changes. I've run into a couple gotchas so far and we'll need to be careful. I think we should make sure to force
cython>=3
in the pyproject.toml. Issues I've run into so far:cdef
functions now default to exceptions being possible (as if you had doneexcept -1
or similar). For many cases of the code I write this isn't what I want. Onnogil
functions this is extra bad because it adds a GIL acquire and release to check the error state. The fix is to donoexcept nogil:
at the end of the function declaration. Checking the HTML output ofcython -a some_module.pyx
makes it pretty clear since ournogil
functions shouldn't have any yellow (non-C code).