pybind/pybind11

Support for dataclasses

Open

#2065 aperta il 10 gen 2020

Vedi su GitHub
 (1 commento) (8 reazioni) (0 assegnatari)C++ (2005 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (14.677 star)
Metriche merge PR
 (Merge medio 5g 2h) (10 PR mergiate in 30 g)

Descrizione

pybind11 talks of course about how to wrap C++ classes so that they are accessible in python. The issue for me is that on the python side of things, we are using dataclasses very extensively. They provide a lot of useful built in features as well as type annotations that you can use with mypy. If you are wrapping a C++ class, then obviously, all the types are already present, so in principle it would be possible at no extra cost to export a dataclass rather than a regular python class, which would be really useful.

Maybe this is not possible to do from a purely C/C++ module, but if it is it would be pretty amazing.

Guida contributor