Mutable C++ lvalue arguments for immutable or rvalue Python types
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
I was wondering whether pybind11 happily accepting this kind of functions could be misleading:
.def("f", [](int& x) { x = 42; })
One may assume that pushing back to a std::vector<>& would update the list (although a related example is in the docs). Basically, for non-opaque types that require type conversion, is it possible to disable passing them as non-const refs, or do we not have this info at compile time?
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 no file or test entry point. Start by tracing pybind11's conversion handling for non-opaque types and mutable lvalue references, using the shown lambda and the related vector example in the documentation as starting points. Done means determining whether these bindings can be rejected safely and covering the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100