Skip to content
An example of building a Python library on top of an existing Go package
Go Jupyter Notebook C Python Makefile
Branch: main
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
LICENSE
Makefile
README.md
example.ipynb
gocrypt.go
gocrypt.py
gocrypt_test.go
gocrypt_test.py

README.md

Using Go from Python

This repository is a toy example of using Cgo and Python's C FFI to effectively reuse Go code from Python. Tested on Go 1.12+, Python 3.8+.

Notes:

  • In the lib dir, one does not need the generated C header file. It can be useful, however, for understanding how Cgo generates code.
  • Required Python packages: To run tests, pytest is required. To try the example notebook, jupyter is required.

Usage

Build shared C lib, run Go and Python unit tests:

$ make

Cleanup:

$ make clean

Explore with Jupyter Notebook:

$ jupyter notebook # then open example.ipynb

© 2020 Damien Stanton

See LICENSE for details.

You can’t perform that action at this time.