From f2a056710e6b614cf7dfec17c2e860acd2eddbcc Mon Sep 17 00:00:00 2001 From: jakirkham Date: Mon, 21 Oct 2024 11:39:33 -0700 Subject: [PATCH] Mark all of `Array`'s `nogil` `cdef` functions as `noexcept` (#502) 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: https://github.com/rapidsai/kvikio/pull/502 --- python/kvikio/kvikio/_lib/arr.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/kvikio/kvikio/_lib/arr.pyx b/python/kvikio/kvikio/_lib/arr.pyx index 45c7430313..d26b139e92 100644 --- a/python/kvikio/kvikio/_lib/arr.pyx +++ b/python/kvikio/kvikio/_lib/arr.pyx @@ -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 @@ -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 @@ -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) @@ -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]