We directly call malloc in a few places in NumPy. Overall, and especially historically, this is fine.
However, Python now defaults to mimalloc sometimes and I am not sure we pick that up.
So it would make sense to use PyArray_malloc (or maybe just the PyMem_RawMalloc that it aliases).
In some places using the customizable array allocator could also make sense (I personally don't think it makes sense at least for small temporaries used internally, but there may be some places where the allocation leaks outside of NumPy itself and then it could make sense).
We directly call
mallocin a few places in NumPy. Overall, and especially historically, this is fine.However, Python now defaults to
mimallocsometimes and I am not sure we pick that up.So it would make sense to use
PyArray_malloc(or maybe just thePyMem_RawMallocthat it aliases).In some places using the customizable array allocator could also make sense (I personally don't think it makes sense at least for small temporaries used internally, but there may be some places where the allocation leaks outside of NumPy itself and then it could make sense).