None support in builtin casters
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Currently, it's not possible to pass None to arithmetic casters, e.g.
m.def("is_none", [](const int* x) { return !x; });
would not accept a None (unlike class_-defined types).
This also applies to other builtin casters -- e.g. it doesn't work for std::string*, but does for const char* (due to how the caster works).
As one potential solution, it may be nice to have py::arg().none(true) affect these cases as well (or allow None by default, like it is for user-bound types).
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 from the builtin arithmetic and std::string* caster paths described in the issue, comparing them with class_-defined types and const char*. Determine whether py::arg().none(true) or default acceptance is intended; done means the examples accept None consistently and relevant behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100