Request for "tagging" arguments with default without needing to duplicate the default values
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Could pybind11 support default arguments for constructors without having to repeat the defaults, using something like this:
py::class_<Foo> c(m, "Foo");
c.def(py::init<
const std::shared_ptr<bar>&,
const std::array<double, 3>&,
py::optional<
const double,
const double
>
>());
this would be shortcut for:
py::class_<Foo> c(m, "Foo");
c.def(py::init<
const std::shared_ptr<bar>&,
const std::array<double, 3>&,
>());
c.def(py::init<
const std::shared_ptr<bar>&,
const std::array<double, 3>&,
const double
>());
c.def(py::init<
const std::shared_ptr<bar>&,
const std::array<double, 3>&,
const double,
const double
>());
Note that Boost.Python supports this syntax.
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 by reading the proposed py::class_ and py::init syntax and compare it with the linked Boost.Python optional initializer documentation. Determine how the requested tagging form should expand to the shown constructor overloads without repeating defaults. Done means pybind11 supports the proposed default-argument syntax with equivalent constructor behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100