Settings

Theme

Ask HN: Real world examples of interaction between Python and Go?

6 points by wareotie 8 years ago · 4 comments · 1 min read


My manager allows me to use some of my time on personal projects so I started a library for an internal tool. More as a learning project that anything else, but now, it seems is useful for other people.

The thing is, the library is completely written in Go and I would like to use it as a Python library.

I found a few blog posts but I cannot find real world examples of libraries written in Go but been use from Python and I feel a little lost.

Anyone knows public repos like this?

itamarst 8 years ago

Sadly the experiment I did isn't public. My memory is I compiled the Go thing to a shared library, and exposed a C API, and then used cffi to talk to the C API (based on https://blog.filippo.io/building-python-modules-with-go-1-5/, except cffi instead of Python C API).

Go objects needed to be managed C style: internally Go thing had a map between integer identifier and object, and Python just got the integer identifier and had to manually tell Go code to deallocate.

  • cakes 8 years ago

    I was recently trying to do something similar and looked/tried go as a solution but I ran into some initial issues around my own confidence that the shared lib would work and that I wouldn't eventually really mess up the deallocation step.

    • itamarst 8 years ago

      I'm not sure I'd recommend it, yeah...

      • wareotieOP 8 years ago

        Thanks for the suggestion. In fact, I'm thinking in dropping the idea and port it, but I'm not confident with my Python skills and there are plenty of concurrency stuff in the library.

        Well, I guess is time to learn Python

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection