Skip to content
raphael valentin edited this page Oct 25, 2017 · 8 revisions

Welcome to the golang_to_python wiki!

golang_to_python shows a simple example how to create a python module that includes a golang code with its wrapping interfaces just by using a cython script as a wrapper. We can note that using this strategy, it allows to simplify the wrapping interface between golang and python by:

  1. removing cgo preamble code such as shown in https://blog.filippo.io/building-python-modules-with-go-1-5/,
  2. improving the wrapping interface compatibility allowing different version of Python for same code (e.g. no more #include Python.h header in the golang code).
  3. interfacing third party libraries such numpy into the cython script (https://github.com/ryanbressler/numpy2go/blob/master/numpy2go.py).

Finally, the golang code and python scripts can just become clean!

This simple example has been tested with

  • ubuntu, gnome3
  • golang = 1.9
  • python = 2.7
  • cython = 0.26
Clone this wiki locally