It is a toy project for Python and Rust!
Project description
项目介绍
这是一个 Python 和 Rust 混合编程的项目,主要目的是比较 Rust 和 Python 的性能差异。目前这个项目是 rshare,我们 在项目中通过 PYO3 和 Maturin 来将 Rust 代码包装到 Python 中,以使得用户可以通过 Python 代码来调用 Rust 写的函数。当然其中是有性能损失的。
说明
目前已经支持 64 位操作系统,包括 Windows,Linux,macOS 和 ARM64 架构的 Linux 系统。
安装
通过 pip install rshare --upgrade -i https://pypi.org/simple
来安装 rshare
体验 Rust 的极致性能!
使用
import time
import numpy as np
import rshare as rk
import talib
data_num = 100000000
data_np = np.random.rand(data_num)
timeperiod = 10
# Rust 和 C 对比
start_py = time.time()
result_talib = talib.SMA(data_np, timeperiod)
end_py = time.time()
print(f"基于 C 语言的 TA-Lib 耗时: {end_py - start_py} seconds")
start_py = time.time()
result_np_rs = rk.calculate_moving_average_rs(data=data_np, window_size=timeperiod)
end_py = time.time()
print(f"基于 Rust 的耗时: {end_py - start_py} seconds")
构建
maturin build
maturin develop --release
版本说明
目前主要是说明开发的软件版本:
- Python 3.11
- Rust 1.74.1
注意事项
需要重新编译部分内容
更新
- 推送到 main 分支
- 修改
Cargo.toml
中的版本号 - 打标签:
git tag v0.1.7
- 通过推送标签进行升级:
git push origin tag v0.1.7
镜像推送
- 基于原始镜像:
ghcr.io/rust-cross/manylinux2014-cross:aarch64
docker build -t jindaxiang/newopen .
docker tag local-image:tagname jindaxiang/new-repo:tagname
docker push jindaxiang/new-repo:tagname
查看
贡献代码
关注 .vscode
用于 debug 代码,新增 .vscode 文件夹
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rshare-0.1.19.tar.gz
(25.9 kB
view hashes)
Built Distributions
Close
Hashes for rshare-0.1.19-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c6a83f60d46d81f43abc6b333a0e378b28a2137d7ac4795be9a9705a06f06d |
|
MD5 | 5289258d9157ec036b12a85a62a61dd4 |
|
BLAKE2b-256 | 6193a21c3342c30f78e5a454293bd6a13f78ca26ca6692a5e2272a06ca5b54e3 |
Close
Hashes for rshare-0.1.19-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9078eb58c3b318c85a368d22bb844f999da8d90a8091ea3eccbaca4096e96893 |
|
MD5 | f5a2c260b43db396076a5464850837ab |
|
BLAKE2b-256 | 1bcab1fbae6b0a82ea4f6f87531dfe14058d5eb41b9c2aa040a8661ca6e7c226 |
Close
Hashes for rshare-0.1.19-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d954058043578026311f88fb590fd07eb13466d40c7e1960e372cb627810533 |
|
MD5 | b76ea210c0290bfa89c1cc0f5c075d53 |
|
BLAKE2b-256 | b5576406c33e6d81357eacea79234731e592cc089991a7ca68afd23ffd3af190 |
Close
Hashes for rshare-0.1.19-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9e41704d3eb3334b9b42c3eaec867a6ebd0139f2b0ac44eaba96242c5a1322c |
|
MD5 | 41f8f11378c9722659052a9f8dfaa3f2 |
|
BLAKE2b-256 | b1d60aaa51efe331f7612fdf38ff4945e7aa20d5595f8d909c7474e30794c410 |
Close
Hashes for rshare-0.1.19-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9508b06a84d7d8ef58b47d7ad483798ead77850ac7d256231aa99a3a744a8e |
|
MD5 | af183f679c3428f10cf94b830ec1c980 |
|
BLAKE2b-256 | 23acb537bf380e859d43648a565102213514ac9b92e3a1c44b4b66beaf511900 |