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 talib
import rshare as rk
# Rust 和 C 对比
start_py = time.time()
result_talib = talib.SMA(data_np, timeperiod)
end_py = time.time()
print(f"Talib took: {end_py - start_py} seconds")
start_py = time.time()
result_np_rs = rk.calculate_moving_average_rs(data_np, timeperiod)
end_py = time.time()
print(f"RSNP took: {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.17.tar.gz
(25.6 kB
view hashes)
Built Distributions
Close
Hashes for rshare-0.1.17-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee8d99e3622766e92d8f1eab93b145e16933f9bcfb69930c914bb7823eb0d56 |
|
MD5 | 56ac49549804dffa928de6ab5f101468 |
|
BLAKE2b-256 | 1ef7fce44b40cfb8739d0ecd8063d8cd77468b0b246f0a29f16374c3eed5e99e |
Close
Hashes for rshare-0.1.17-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a65d12898327bc27c46a2b161a5087edfe4bcf376d496022d896e8291eeeafe |
|
MD5 | 6cb3fd4e578860d793bdd1c927df70cd |
|
BLAKE2b-256 | 4334fe7cf683259a45beacc45ce488aaa59312e0fabcb952a8d444b7767fa684 |
Close
Hashes for rshare-0.1.17-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a34f73e575b769bff6ae5db226d3ee8eb872011445186fb69f004c547580f76 |
|
MD5 | 82fa51cb80dde31d079ac8c35f576c36 |
|
BLAKE2b-256 | 6440cede5a528cca27e48ba669983dd148c57d302277c8c32eff2c797d9d1749 |
Close
Hashes for rshare-0.1.17-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 466068c631be1f421c3727164170ba7c78b7691c75bd72fc818c2bf6f5c290a6 |
|
MD5 | d97878a17385406a92389ff6a2f73aae |
|
BLAKE2b-256 | c720b84ab821ac1ee9336a001e52b8006fc621f2bb76e2af8c5172a357bde948 |
Close
Hashes for rshare-0.1.17-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce6d4cc680762e88bc2d34858553c67cc5026b3ae34b4c3b9f16888a84c28ace |
|
MD5 | 35e960a62574b9ae19463ec17a98c024 |
|
BLAKE2b-256 | 381c564fab979ce92a4bd9bfad10498f65e217bc17ca8a161261dbc93a4b8257 |