Skip to content

v0.8.1

Choose a tag to compare

@xushiwei xushiwei released this 12 May 17:03
· 7196 commits to main since this release
1463ed4

highlights:

  • Now you can import a Python library in llgo!

features:

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.