Skip to content

Commit

Permalink
Add noexcept to _utils C-equiv functions (#641)
Browse files Browse the repository at this point in the history
* Add `noexcept` to `_utils` C-equiv functions

The functions in `_utils` are effectively straight C functions. In
Cython 0.x, these would have been treated as `noexcept` by default.
However in Cython 3.x all functions are treated as potentially raising
exceptions (including these). While that is a sensible default in
general, these functions still won't raise exceptions. So tidy things up
by adding `noexcept` to turn off the additional Cython checks emitted in
and around them.

* Swap order of `nogil` & `noexcept`

Fixes a Cython warning when using the opposite ordering.

* style: pre-commit fixes

---------

Co-authored-by: David Stansby <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 4cd03c9 commit a345db6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Fixes
* Cleanup ``crc32c`` soft dependency.
By :user:`John Kirkham <jakirkham>`, :issue:`637`

Improvements
~~~~~~~~~~~~
* Add `noexcept` to `_utils` C-equiv functions
By :user:`John Kirkham <jakirkham>`, :issue:`641`.

.. _release_0.14.0:

Expand Down
4 changes: 2 additions & 2 deletions numcodecs/_utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from libc.stdint cimport uint8_t, uint32_t


cdef inline void store_le32(uint8_t c[4], uint32_t i) nogil:
cdef inline void store_le32(uint8_t c[4], uint32_t i) noexcept nogil:
c[0] = i & 0xFF
c[1] = (i >> 8) & 0xFF
c[2] = (i >> 16) & 0xFF
c[3] = (i >> 24) & 0xFF


cdef inline uint32_t load_le32(const uint8_t c[4]) nogil:
cdef inline uint32_t load_le32(const uint8_t c[4]) noexcept nogil:
return (
c[0] |
(c[1] << 8) |
Expand Down

0 comments on commit a345db6

Please sign in to comment.