[QUESTION] Numpy Array to C++ - take ownership of data
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Is it possible to pass data from numpy to C++ and take ownership of the 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names py::buffer_info as the entry point; start by reviewing its documented buffer lifetime and ownership constraints, then inspect any related ownership or capsule guidance in the repository. Done means establishing whether transferring NumPy memory ownership is supported without copying and identifying the documented API or limitation; no file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, numpy, python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100