Description
At present, type_caster
is something that exists in the py::detail
namespace, but may be overloaded in downstream applications, either via a macro, or more directly.
A naive downstream example (that I wrote 😬):
https://github.com/RobotLocomotion/drake/blob/v0.25.0/bindings/pydrake/common/wrap_pybind.h#L54-L114
https://github.com/RobotLocomotion/drake/blob/v0.25.0/bindings/pydrake/common/cpp_param_pybind.h#L149-L158
At present, my reading of py::detail
is that it's generally internal implementation details, i.e. it's internal, not public API, and should not be expected to be stable.
It seems like the base contract of py::detail::type_caster
may more-or-less be leaked into a public details. We may want to consider making this more public, and having some level of public stability for this. In this way, we could hoist it outside of py::detail
, so we could keep that reserved for truly internal details.
Possibly related:
- [FEAT] Rework casting #2646 - holders (may be internal, but may motivate public contract for holder-type casters)
- [BUG] Documentation suggests that custom type casters do not need to clear exceptions #2732 - contract - exception handling
- Revising the design of type_caster<T>::load() #864 - mention backwards-compatibility, which mentions some semblance of stabliity