Open jiawen opened 1 year ago
How similar are the nanobind type_caster
s to the pybind11 one? Could we just have the nanobind casters inherit from the pybind11 casters?
If not, to not develop a severe case of copy-pasteritis, we'd need to factor out the guts of the type conversions into core from-python and to-python functions, then hook them into the type_caster
frameworks for pybind11 and nanobind.
Interesting perspective. AFAICT, they're identical, except for changing the namespace. But of course there could easily be some odd corners where they differ (in particular, the removal of the holder concept when dealing with smart pointers).
I suppose there's only one way to find out - I will attempt a copy paste and see what happens to the tests.
Re: inheritance - would that not introduce a dependency on pybind11 as well as nanobind? This can easily increase binary size.
the removal of the holder concept when dealing with smart pointers).
I don't think there is a connection between type_caster_base
and other type_caster
s in this respect.
This can easily increase binary size.
Duplicating all casters & then having to maintain everything twice is far worse. Of course divergence will appear ~immediately, creating a whack-a-mole game. (The "far worse" aspect is probably not very obvious for a single project in isolation, but I'm working with a gigantic codebase in a mono repo, it's very clear then how much human time is lost when something is copy-pasted like nanobind was.)
Re: inheritance - would that not introduce a dependency on pybind11 as well as nanobind?
Another ~easy solution is to factor our generic casters and inherit in the pybind11::detail
and nanobind::detail
namespaces.
My 2 cents, Google Benchmark seems to use nanobind... https://github.com/google/benchmark/tree/main/bindings/python
Nanobind looks fairly stable at this point. I recently got nanobind to work with my various Bazel projects and considering doing a port.
Are there any plans to release a
nanobind_abseil
? If not, I'm happy to take a stab at it in my spare time.