generics #2149
Replies: 1 comment
-
I don't think it's likely that #[pyclass]
struct GenericType<T> {
inner: T
} will be a first-class PyO3 feature, at least not without some very well-written design proposal on how this should be treated. The reason is that (I assume) each instantation The best alternative, which works already, is to write a macro which expands to a new To clarify, I'm willing to hear proposed additions to PyO3's API to support this. I just think it's a very hard problem to solve cleanly, and if it makes the core PyO3 code harder to maintain, I would want us to consider the tradeoff whether it's worth it when we already can write solutions using macros. Similarly, it would be very cool to have a |
Beta Was this translation helpful? Give feedback.
-
From looking through some older issues and by trying i found that generics and custom traits are not supported by pyo3.
Is that something that is on the roadmap?
or is it an "impossible" issue?
I am used to using pybind11's interface which allows for py::class_ being defined in (templated) functions, making it easy to bind existing libraries. I think there is no counterpart in pyo3 and probably this is impossible too?
As one can use multiple-pymethods feature, i guess the best way to get close to generics would be to implement a macro to create several impl's at once and specialization after that. would that be possible?
Beta Was this translation helpful? Give feedback.
All reactions