您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Go 语言编写 CPython 扩展 goPy

2025/9/18 11:30:00发布41次查看
gopy 是一个新的开源项目,实现了用 go 语言来编写 cpython 扩展。
示例代码:
package simple import ( fmt gopy ) func example(args *py.tuple) (py.object, error) { fmt.printf(simple.example: %v\n, args) py.none.incref() return py.none, nil } func init() { methods := []py.method{ {example, example, example function}, } _, err := py.initmodule(simple, methods) if err != nil { panic(err) } }
编译方法:
gopy pymodule.go
使用方法:
import simple
simple.example(hello, {123: true})
输出结果:
simple.example: [hello map[123:true]]
github开源项目地址:https://github.com/qur/gopy
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product