Go 语言编写 CPython 扩展 goPy

码农软件 · 软件分类 · Python开发工具 · 2019-11-12 21:57:01

软件介绍

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]]

本文地址:https://codercto.com/soft/d/18860.html

Data Structures and Algorithm Analysis in Java

Data Structures and Algorithm Analysis in Java

Mark A. Weiss / Pearson / 2006-3-3 / USD 143.00

As the speed and power of computers increases, so does the need for effective programming and algorithm analysis. By approaching these skills in tandem, Mark Allen Weiss teaches readers to develop wel......一起来看看 《Data Structures and Algorithm Analysis in Java》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试