Add a wrapper for namedtuple?
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
I'd love to write C++ code that does something like this:
typedef py::namedtuple<"MyTuple", int, "arg1", py::str, "arg2"> MyTuple;
MyTuple function() {
return MyTuple(42, "string");
}
PYBIND_MODULE(Module, m) {
m.register(MyTuple);
}
I suspect the tricky bit would be accessing the PyTypeObject associated with the named tuple.
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 files or tests; begin by locating the binding API entry points corresponding to the proposed py::namedtuple, PYBIND_MODULE, and m.register usage. Investigate how the associated PyTypeObject would be accessed, and consider the work complete when the demonstrated MyTuple declaration, function return, and module registration pattern can be supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100