I want to write golang bindings for an existing (third party) Python module. The purpose is that I want to use the API that the Python module provides in Golang.
I already found golang bindings for Python's C API (go-python3 for py3 and go-python for py2), but I still haven't figured out how to translate a relatively complex Python module into Golang (i.e. how to deal with type safety in go for unsafe inputs and returns in python, etc).
What would be a good approach? Are there any pre-existing tools in that space? Are there any good examples for Golang bindings for Python code? (I couldn't find many tbh).
But we still can call Python in memory from Go (as a shared library), which is relatively fast. So compared to the shared memory solution from the Ardan Labs blogpost I'd argue it's a tradeoff for more approachability at the cost of reduced efficiency.
I want to use the API that the Python module provides in Golang.
Calling Python from Go is detailed recently in "Python and Go : Part I - gRPC" by Miki Tebeka.
You can see an example in ardanlabs/python-go/grpc
But, as shown in their next two articles, you can also:
Full example: ardanlabs/python-go/pyext
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With