Borrow checking should use a capsule API
adamreichold opened this issue · 0 comments
The dynamic borrow checking currently uses Rust static global data to store the currently active borrows which means that it is limited to checking the borrows by a single statically linked extension but not e.g. across two separate extensions using rust-numpy.
I think the best way to mitigate this is to use a capsule API providing a C API/ABI for the basic borrow checking operations with the global state being attached to a Python module, e.g. an attribute named _BORROW_CHECK_API injected into the numpy.core.multiarray module. This would enable both multiple extensions using rust-numpy to share borrow checking data as well as extensions written in other languages to participate in borrow checking.