compare_buffer_info does not consider <i and i equal on a little-endian machine
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
The compare_buffer_info template will reject buffer formats of <i and i as being different.
This can be observed by calling bind_vector on vector<int32_t> with py::buffer_info(), then attempting to construct one as:
arr = (ctypes.c_int32 * 10)()
MyVector(arr)
# TypeError: TypeError: Format mismatch (Python: <i C++: i)
<i means "little endian int", and i means "native int". On a little-endian machine, these should be considered compatible.
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
Start at the compare_buffer_info template and reproduce the mismatch through bind_vector with py::buffer_info, using the ctypes.c_int32 example from the issue. Done means little-endian '<i' and native 'i' formats are accepted as compatible on little-endian machines without rejecting genuinely incompatible formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100