highlights:
- Now you can import a Python library in llgo!
features:
- import python library (#140 #145 #146 #148 #149 #150 #151 #152 #154)
- py demo: hellpy, clpy, callpy (#140 #141 #142 #145 #148 #152 #153 #154)
- typeAssert: bool, float, string (#139)
changes:
- llgo/ssa: fix types named recursive (#147)
- mv
x/<tool>=>xtool/<tool>(#143) - nmindex: query auto add _ prefix (#144)
Python support
You can import a Python library in llgo! For example:
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/py"
"github.com/goplus/llgo/py/math"
)
func main() {
x := math.Sqrt(py.Float(2))
c.Printf(c.Str("sqrt(2) = %f\n"), x.Float64())
}Here, We call py.Float(2) to create a Python floating point number 2, and pass it to Python’s math.sqrt to get x. Then use x.Float64() to convert the Python object to Go's float64 type, and finally we print the value through C printf.