Skip to content

Commit

Permalink
Mark all of Array's nogil cdef functions as noexcept (#502)
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]( https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#exception-values-and-noexcept ) in these functions, which is unnecessary given none of these set exceptions. So add `noexcept` to turn off these Cython checks.

Authors:
  - https://github.com/jakirkham

Approvers:
  - Mads R. B. Kristensen (https://github.com/madsbk)

URL: #502
  • Loading branch information
jakirkham authored Oct 21, 2024
1 parent a34d6bf commit f2a0567
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 f2a0567

Please sign in to comment.