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 rshare as rk
# Rust 接口
fetch_title_str = rk.fetch_title(url="https://www.baidu.com")
print(fetch_title_str)
# Python 接口
fetch_name_str = rk.fetch_name(url="https://www.baidu.com")
print(fetch_name_str)
# Rust 接口测试计算 5 日均线
result_rs = rk.calculate_moving_average_rs(data=[10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0] * 10000000, window_size=5)
print(result_rs)
构建
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.15.tar.gz
(29.1 kB
view hashes)
Built Distributions
Close
Hashes for rshare-0.1.15-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd6d45b1cd2d77eaa044bd91b171b56afb854f4f28345a42e87376138192ab0 |
|
MD5 | ea3a70832372fbd96883e451ea315256 |
|
BLAKE2b-256 | ef64eeea3867a583311ce21b5f1c29a1e8f58d52bad5c64a126e85c16629e084 |
Close
Hashes for rshare-0.1.15-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56eed83fb6f85a3e186c5c049c3fdb1029c757543977179c1e6295601cdac6b6 |
|
MD5 | 9ab6497c2dfa356e14eb59f51f4b7b48 |
|
BLAKE2b-256 | c38827e89d7f1b8af4a6c87838847993579ce205662f46ce7f77feab97c47b6d |
Close
Hashes for rshare-0.1.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9d2b7d4383489b86a5f512d743b9b2a5bb8eb0d4dd3cd5506e1708c6808a36 |
|
MD5 | 219c41028bbd38e4939573477c50a66c |
|
BLAKE2b-256 | 3e0dedda125286e7a268dd65a5b7052b340fd235ad449870fa1ac4ef954e7a58 |
Close
Hashes for rshare-0.1.15-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1227d373fe4d9c9d925885457bf3c424df8880f498bfcf8139e071475738fc5f |
|
MD5 | 04e79a54fd016229b746f9e24dec9d27 |
|
BLAKE2b-256 | e45557bdd522adb37b0f12751a46cbe0ad627cd9ed2bafd61781fa5014175e45 |
Close
Hashes for rshare-0.1.15-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 082974899c4f463addb7db488af142dc41fdc581ec0dbd9d1260483e0627cef0 |
|
MD5 | 94bc400c60c692204d9ebb5fb2ed1666 |
|
BLAKE2b-256 | d7fc7a384767d4c7d2efc04e924a1602d6265f8829ffef3a4c741157d226f728 |