would like numpy to add a hook when it allocates arrays
This issue may belong in another place but for tracking purposes I added it here. It would be nice if numpy not only allocated on 32byte or 64byte boundaries, but did so in an official way (often leaving magic markers to the memory just behind the original pointer) that could be hooked. This would allow a new array memory allocator to hook how numpy arrays are allocated offering features such as array recycling or numa node allocations.
In the future it could be used to allocate arrays that span multiple computers.
numpy/numpy#17467
Now has a PR numpy/numpy#17582, please check that it has the desired features.
The current API allows overriding alloc/calloc/free/realloc. Is there a reason to add memcpy overrides for host2obj, obj2obj, obj2host? Do you see a reason this would ever not be memcpy? I don't think GPU arrays are in scope at this time.
The upcoming 1.22 release of NumPy will include configurable allocators.
Thanks for pushing the idea and helping with the design.