What is gopy
mastergopy is a tool that generates and compiles a CPython extension module from a Go package. It allows you to use Go code within Python by creating bindings.
Key features include:
- Safety: Uses unique
int64handles to interface with Python instead of raw pointers, making it safe for Go's moving garbage collector. - Multi-package support: Supports Python modules containing multiple Go packages. It generates a separate
.pymodule file for each package, which link into a single common binding library. - Callbacks: Supports calling Python functions from Go. You can pass a Python function as an argument to a Go function.
- Inheritance: Uses the first embedded struct field in Go to establish corresponding class inheritance in the Python wrappers, allowing efficient inheritance of methods and properties.