AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO
[FEATURE REQUEST] ImageBuf "wrap" numpy array in python
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 698
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 47
Description
In C++, it is straightforward to construct an ImageBuf that "wraps" an existing buffer without owning the memory, where you just give it the pointer to the memory and the strides.
There's not currently an equivalent in python, but there should be! It's a great idea suggested by a question from João Vítor Silva on the slack channel. We could imagine a Python-side IB constructor that takes a numpy ndarray and knows it's just a reference to that data and not to do any copies or ownership. (With the caveat that you need to ensure that you don't change the shape or where the data lives in the numpy array, because the IB that wraps it would have no way of knowing.)
Contributor guide
Research direction
No source files or tests are named. Start by locating the Python ImageBuf binding and the existing C++ ImageBuf buffer-wrapping constructor, then trace how ndarray inputs are handled. Done means Python can wrap a NumPy array without copying or taking ownership, with coverage for the stated lifetime and shape caveat.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, numpy, python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100