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 = 1000000
data_np = np.random.rand(data_num)
timeperiod = 50
# 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.18.tar.gz
(25.6 kB
view hashes)
Built Distributions
Close
Hashes for rshare-0.1.18-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16fafa940b61dcf02ff5f33004fd0b9ce58928dc49259a002f2f359edc045886 |
|
MD5 | 5129ac3c57f4bf67fbfd42d2dc04d7eb |
|
BLAKE2b-256 | a8068b36055ec16b78a5e717862dee86000bec9c3490d15ba8c1e9ef669a3b20 |
Close
Hashes for rshare-0.1.18-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adb6a7b5bd0fdfdfa31884c72f1886f3c2cf12d12d38ee2f30653b8483f12119 |
|
MD5 | 515038a160ccfdc3fad60a530ad55c72 |
|
BLAKE2b-256 | 1ab43a5b7211e0a5a87138dcf1eb44289f8539d694048b25eaa3a8b772a55e45 |
Close
Hashes for rshare-0.1.18-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef6391f22a566f923817d6bb4fcc2da6b76baa0050211e7d85635c443881324c |
|
MD5 | 715b061fbe61577a6edc088ca86ecdc3 |
|
BLAKE2b-256 | e19feccb43976aa19cd479e305697507c1e780f2e8bac387fb90c860c001e9a6 |
Close
Hashes for rshare-0.1.18-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b818fe0329865396784adf3589196ffeb0e6b9ad5605ab8aa9890f66de9f3de |
|
MD5 | 23b023d88baa5fcee48beb5244d19c9b |
|
BLAKE2b-256 | 8c68dbd49b7b554f7d5c293528b33e8cc681f84397645821bcbde3174c374590 |
Close
Hashes for rshare-0.1.18-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8910dd7ff5d8eded5c16655b94d97c77014ea42456ee992b5e8d461952e72cd0 |
|
MD5 | f976938f45ec96270dcb5b537ff1a901 |
|
BLAKE2b-256 | 2ece6b4140e5a891ceb4354676a37f6e2cc3f3a3ef3789a789b8f8e2f23301ec |