pybind / pybind/pybind11

Mutable C++ lvalue arguments for immutable or rvalue Python types

Open
#823 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

casters enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.