Using goPy in combination with gccgo it is possible to write CPython extension modules in Go. Once the libraries and command-line tool are installed, the "gopy" command-line tool takes care of generating the necessary C interface code and using gccgo to compile the code into an extension module.
These are the new features in 0.8.0:
- Some support for calling Go code from external theads (see caveat below).
- Support for creating a Go executable that embeds Python and which can also load Go extension modules (-exe flag to gopy)
- Gccgo version support updated to 4.7.3
- Misc fixes pulled in from GC goPy sources.
There are a few things that should be made clear:
- Calling Go code from a second thread will block that thread, whilst the Go code is called by a goroutine running in a thread controlled by the Go runtime. Most of the time this should be invisible, but it could cause problems if that Go code then calls back out to something that expects to be running in the same thread.
- Both the goPy bindings and the gccgo specific extension support code have only undergone the lightest of testing
- When using goroutines py.Lock must be used. No other GIL or threading interface functions have been tested - and they most likely will not work.
- Essentially this code is alpha quality at best, and currently primarily exists as proof that it is possible.