Skip to content

Commit

Permalink
fix(performance warnings): by adding noexcept
Browse files Browse the repository at this point in the history
  • Loading branch information
nauaneed committed Aug 15, 2024
1 parent 40094ee commit dedb698
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions cyarray/carray.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Declaration File.
# numpy import
cimport numpy as np

cdef long aligned(long n, int item_size) nogil
cdef void* aligned_malloc(size_t bytes) nogil
cdef void* aligned_realloc(void* existing, size_t bytes, size_t old_size) nogil
cdef void aligned_free(void* p) nogil
cdef long aligned(long n, int item_size) noexcept nogil
cdef void* aligned_malloc(size_t bytes) noexcept nogil
cdef void* aligned_realloc(void* existing, size_t bytes, size_t old_size) noexcept nogil
cdef void aligned_free(void* p) noexcept nogil

# forward declaration
cdef class BaseArray
Expand All @@ -31,7 +31,7 @@ cdef class BaseArray:
cdef np.ndarray _npy_array

cdef void c_align_array(self, LongArray new_indices, int stride=*) nogil
cdef void c_reserve(self, long size) nogil
cdef void c_reserve(self, long size) noexcept nogil
cdef void c_reset(self)
cdef void c_resize(self, long size) nogil
cdef void c_squeeze(self) nogil
Expand Down
10 changes: 5 additions & 5 deletions cyarray/carray.pxd.mako
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Declaration File.
# numpy import
cimport numpy as np

cdef long aligned(long n, int item_size) nogil
cdef void* aligned_malloc(size_t bytes) nogil
cdef void* aligned_realloc(void* existing, size_t bytes, size_t old_size) nogil
cdef void aligned_free(void* p) nogil
cdef long aligned(long n, int item_size) noexcept nogil
cdef void* aligned_malloc(size_t bytes) noexcept nogil
cdef void* aligned_realloc(void* existing, size_t bytes, size_t old_size) noexcept nogil
cdef void aligned_free(void* p) noexcept nogil

# forward declaration
cdef class BaseArray
Expand All @@ -39,7 +39,7 @@ cdef class BaseArray:
cdef np.ndarray _npy_array

cdef void c_align_array(self, LongArray new_indices, int stride=*) nogil
cdef void c_reserve(self, long size) nogil
cdef void c_reserve(self, long size) noexcept nogil
cdef void c_reset(self)
cdef void c_resize(self, long size) nogil
cdef void c_squeeze(self) nogil
Expand Down
20 changes: 10 additions & 10 deletions cyarray/carray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ cdef extern from "stdlib.h":
# numpy module initialization call
_import_array()

cdef inline long aligned(long n, int item_size) nogil:
cdef inline long aligned(long n, int item_size) noexcept nogil:
"""Align `n` items each having size (in bytes) `item_size` to
64 bytes and return the appropriate number of items that would
be aligned to 64 bytes.
Expand Down Expand Up @@ -124,13 +124,13 @@ cdef void* _deref_base(void* ptr) nogil:
raise MemoryError("Passed pointer is not aligned.")
return <void*>base

cdef void* aligned_malloc(size_t bytes) nogil:
cdef void* aligned_malloc(size_t bytes) noexcept nogil:
return _aligned_malloc(bytes)

cdef void* aligned_realloc(void* p, size_t bytes, size_t old_size) nogil:
cdef void* aligned_realloc(void* p, size_t bytes, size_t old_size) noexcept nogil:
return _aligned_realloc(p, bytes, old_size)

cdef void aligned_free(void* p) nogil:
cdef void aligned_free(void* p) noexcept nogil:
"""Free block allocated by alligned_malloc.
"""
free(<void*>_deref_base(p))
Expand All @@ -146,7 +146,7 @@ cdef class BaseArray:
"""
pass

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
pass

cdef void c_reset(self):
Expand Down Expand Up @@ -425,7 +425,7 @@ cdef class IntArray(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down Expand Up @@ -934,7 +934,7 @@ cdef class UIntArray(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down Expand Up @@ -1443,7 +1443,7 @@ cdef class LongArray(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down Expand Up @@ -1952,7 +1952,7 @@ cdef class FloatArray(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down Expand Up @@ -2461,7 +2461,7 @@ cdef class DoubleArray(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down
12 changes: 6 additions & 6 deletions cyarray/carray.pyx.mako
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ cdef extern from "stdlib.h":
# numpy module initialization call
_import_array()

cdef inline long aligned(long n, int item_size) nogil:
cdef inline long aligned(long n, int item_size) noexcept nogil:
"""Align `n` items each having size (in bytes) `item_size` to
64 bytes and return the appropriate number of items that would
be aligned to 64 bytes.
Expand Down Expand Up @@ -133,13 +133,13 @@ cdef void* _deref_base(void* ptr) nogil:
raise MemoryError("Passed pointer is not aligned.")
return <void*>base

cdef void* aligned_malloc(size_t bytes) nogil:
cdef void* aligned_malloc(size_t bytes) noexcept nogil:
return _aligned_malloc(bytes)

cdef void* aligned_realloc(void* p, size_t bytes, size_t old_size) nogil:
cdef void* aligned_realloc(void* p, size_t bytes, size_t old_size) noexcept nogil:
return _aligned_realloc(p, bytes, old_size)

cdef void aligned_free(void* p) nogil:
cdef void aligned_free(void* p) noexcept nogil:
"""Free block allocated by alligned_malloc.
"""
free(<void*>_deref_base(p))
Expand All @@ -156,7 +156,7 @@ cdef class BaseArray:
"""
pass

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
pass

cdef void c_reset(self):
Expand Down Expand Up @@ -438,7 +438,7 @@ cdef class ${CLASSNAME}(BaseArray):
# update the numpy arrays length
arr.dimensions[0] = self.length

cdef void c_reserve(self, long size) nogil:
cdef void c_reserve(self, long size) noexcept nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
cdef void* data = NULL
if size > self.alloc:
Expand Down

0 comments on commit dedb698

Please sign in to comment.