File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -757,6 +757,23 @@ cdef extern from "numpy/arrayobject.h":
757
757
npy_intp PyArray_OverflowMultiplyList (npy_intp * , int )
758
758
int PyArray_SetBaseObject(ndarray, base) except - 1 # NOTE: steals a reference to base! Use "set_array_base()" instead.
759
759
760
+ # The memory handler functions require the NumPy 1.22 API
761
+ # and may require defining NPY_TARGET_VERSION
762
+ ctypedef struct PyDataMemAllocator:
763
+ void * ctx
764
+ void * (* malloc) (void * ctx, size_t size)
765
+ void * (* calloc) (void * ctx, size_t nelem, size_t elsize)
766
+ void * (* realloc) (void * ctx, void * ptr, size_t new_size)
767
+ void (* free) (void * ctx, void * ptr, size_t size)
768
+
769
+ ctypedef struct PyDataMem_Handler:
770
+ char * name
771
+ npy_uint8 version
772
+ PyDataMemAllocator allocator
773
+
774
+ object PyDataMem_SetHandler(object handler)
775
+ object PyDataMem_GetHandler()
776
+
760
777
# additional datetime related functions are defined below
761
778
762
779
Original file line number Diff line number Diff line change @@ -672,6 +672,23 @@ cdef extern from "numpy/arrayobject.h":
672
672
npy_intp PyArray_OverflowMultiplyList (npy_intp * , int )
673
673
int PyArray_SetBaseObject(ndarray, base) except - 1 # NOTE: steals a reference to base! Use "set_array_base()" instead.
674
674
675
+ # The memory handler functions require the NumPy 1.22 API
676
+ # and may require defining NPY_TARGET_VERSION
677
+ ctypedef struct PyDataMemAllocator:
678
+ void * ctx
679
+ void * (* malloc) (void * ctx, size_t size)
680
+ void * (* calloc) (void * ctx, size_t nelem, size_t elsize)
681
+ void * (* realloc) (void * ctx, void * ptr, size_t new_size)
682
+ void (* free) (void * ctx, void * ptr, size_t size)
683
+
684
+ ctypedef struct PyDataMem_Handler:
685
+ char * name
686
+ npy_uint8 version
687
+ PyDataMemAllocator allocator
688
+
689
+ object PyDataMem_SetHandler(object handler)
690
+ object PyDataMem_GetHandler()
691
+
675
692
# additional datetime related functions are defined below
676
693
677
694
You can’t perform that action at this time.
0 commit comments