Rust 和 Python 如何混合使用?
看到一个 Python 的高性能 json 序列化库 —— orjson
orjson is a fast, correct JSON library for Python. It benchmarks as the fastest Python library for JSON and is more correct than the standard json library or other third-party libraries. It serializes dataclass, datetime, numpy, and UUID instances natively.
但是发现了这个库用了 rust 和 python 混合编程!!!

Python 如何调用 Rust 代码?
- 单独起一个 
rust进程然后IPC通讯? Web Socket通讯?jit?
回答:
我知道了,原理就是
- 先 
rust->c API - 再 
python<-c API 
有一个专门的库:pyo3
Rust bindings for Python, including tools for creating native Python extension modules. Running and interacting with Python code from a Rust binary is also supported.

回答:
它哪里调用rust代码了?只是使用了rust代码编写了底层的类库而已。rust编译是静态编译的,直接构建出平台相关的二进制包而已。
Numpy的搞法也是底层的类库直接使用C编写,构建出平台相关的二进制包,这个类库只不过用rust编写了类库而已
以上是 Rust 和 Python 如何混合使用? 的全部内容, 来源链接: utcz.com/p/938228.html


