Skip to content

Commit

Permalink
Mark all nogil cdef functions as noexcept
Browse files Browse the repository at this point in the history
These are all pure C functions implemented in Cython. They do not raise.
Cython 3 adds checks for exceptions in these functions, which is
unnecessary given none of these set exceptions. So add `noexcept` to
turn off these Cython checks.
  • Loading branch information
jakirkham committed Oct 17, 2024
1 parent a34d6bf commit 48638f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/kvikio/kvikio/_lib/arr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ cdef class Array:
cdef inline bint _c_contiguous(Py_ssize_t itemsize,
Py_ssize_t ndim,
Py_ssize_t[::1] shape_mv,
Py_ssize_t[::1] strides_mv) nogil:
Py_ssize_t[::1] strides_mv) noexcept nogil:
cdef Py_ssize_t i, s
if strides_mv is not None:
s = itemsize
Expand All @@ -254,7 +254,7 @@ cdef inline bint _c_contiguous(Py_ssize_t itemsize,
cdef inline bint _f_contiguous(Py_ssize_t itemsize,
Py_ssize_t ndim,
Py_ssize_t[::1] shape_mv,
Py_ssize_t[::1] strides_mv) nogil:
Py_ssize_t[::1] strides_mv) noexcept nogil:
cdef Py_ssize_t i, s
if strides_mv is not None:
s = itemsize
Expand All @@ -270,7 +270,7 @@ cdef inline bint _f_contiguous(Py_ssize_t itemsize,
cdef inline bint _contiguous(Py_ssize_t itemsize,
Py_ssize_t ndim,
Py_ssize_t[::1] shape_mv,
Py_ssize_t[::1] strides_mv) nogil:
Py_ssize_t[::1] strides_mv) noexcept nogil:
cdef bint r = _c_contiguous(itemsize, ndim, shape_mv, strides_mv)
if not r:
r = _f_contiguous(itemsize, ndim, shape_mv, strides_mv)
Expand All @@ -283,7 +283,7 @@ cdef inline bint _contiguous(Py_ssize_t itemsize,
@wraparound(False)
cdef inline Py_ssize_t _nbytes(Py_ssize_t itemsize,
Py_ssize_t ndim,
Py_ssize_t[::1] shape_mv) nogil:
Py_ssize_t[::1] shape_mv) noexcept nogil:
cdef Py_ssize_t i, nbytes = itemsize
for i in range(ndim):
nbytes *= shape_mv[i]
Expand Down

0 comments on commit 48638f2

Please sign in to comment.