GrappleRobotics / libgrapplefrc

Grapple's FRC Vendor Library
Other
3 stars 2 forks source link

Pybind vs Implementation in Python #8

Open spacey-sooty opened 11 months ago

spacey-sooty commented 11 months ago

@JaciBrunning I'd be curious to know your opinion between using Pybind over the native implementation or creating a in Python implementation of the LaserCAN class. I know something like polars uses Rust bindings within Python similar to how the FFI is being used for C++ here, I'd be curious to know what you think the best approach is.

virtuald commented 11 months ago

I hear pyo3 is great for making python libraries.

If you want to publish the resulting wheel so that the robotpy-installer can download it, the wheel needs to be published to artifactory.. but we can hook you up with an account.

spacey-sooty commented 11 months ago

I hear pyo3 is great for making python libraries.

If you want to publish the resulting wheel so that the robotpy-installer can download it, the wheel needs to be published to artifactory.. but we can hook you up with an account.

I had a quick look at that and it looks really good. I'll have a go using that to create it, then when it's just about ready I'll ping you about publishing it so the robotpy-installer can download it.

JaciBrunning commented 11 months ago

Great work @spacey-sooty

I might see if there's some way we can leverage the existing C bindings we have just so it's more DRY, but I imagine that's neither here nor there. PyO3 does provide a very nice interface but I'm a little worried about the amount of extra build system effort it takes. @virtuald I'll have a peek at how we can go about packaging these for dist this weekend :)

virtuald commented 11 months ago

We use robotpy-build to wrap all the wpilib C++ libraries and all the other vendors with pybind11. It's relatively easy to use and fairly robust, so wrapping your C++ library is an easy alternative if you don't want to do the pure rust thing with PyO3.

spacey-sooty commented 1 month ago

Another option thats been getting some usage is nanobind. PhotonVision was considering using it, I know Sleipnir does. Its significantly faster than Pybind11