'Numpy Array to C++ - take ownership of data

Is it possible to pass data from numpy to C++ and take ownership of the numpy.data's memory, so its no longer managed by Python? I have large Numpy matrix and I dont want to copy memory. I can use py::buffer_info and get pointer to the data, but the pointer is not valid when Python is shut down. Another reason is I want to release data from C++ side once I no longer need them.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source