Skip to main content

rti-py — rti-db 的 Python 绑定

真实 rti-db 引擎(Rust)的 PyO3 绑定。阻塞 I/O 操作(open/flush/seal/compact/durable 等待/scan 收集)释放 GIL;put/latest 为纳秒级、持有 GIL。

安装

# 需要 Rust 工具链
pip install maturin
cd crates/rti-py
maturin build --release          # 产出 target/wheels/rti_db-*.whl
pip install target/wheels/rti_db-*.whl

快速上手

import rti_db

db = rti_db.Db("/var/lib/rti", sync="group", group_interval_us=1000)

# 写入:O(1) 无锁入队(~0.2 µs,含绑定开销)
db.put(1, 1_700_000_000_000_000_000, 42.0)

# 持久写入:返回后 kill -9 也不丢
wm = db.put_durable(1, 1_700_000_000_000_001_000, 43.0, timeout_ms=50)

# O(1) 读最新值
ts, v = db.latest(1)

# 范围扫描 / 谓词 / 聚合
for ts, v in db.scan(1, 0, 2**62):
    ...
avg = db.scan(1, t0, t1, agg="avg")

db.flush()
db.compact()

Db() 参数:data_dir(省略 = 纯内存 Deterministic)、sync("group"/"always"/"none")、profile("balanced"/"deterministic")、memtable_max、pool_bytes。

本机实测(Apple Silicon,Python 3.12,含绑定开销)

操作 实测
put 0.21 µs/点 · 4.67M pts/s
latest() 0.17 µs/次
put_durable 水位语义正确(返回 ≥ 本记录序号)
scan 全量 10k 点 6.7 ms

已知构建问题(macOS + Xcode ld_prime)

部分 macOS 工具链上,rustc 经 ld_prime 链接的 cdylib 会触发 dyld 的 "mis-aligned LINKEDIT string pool" 拒绝加载(符号表字符串池 4 字节对齐而非 8)。 这是链接器 bug,与本 crate 代码无关。scripts/fix-macho-linkedit.py 可对已构建的 .so/.dylib 做二进制修补(8 字节对齐 + 重签),本仓库的 开发机即用该脚本验证通过。

Metadata

Release files for rtidb 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for rtidb 0.8.0
File Interpreter ABI Platform
rtidb-0.8.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Release files / rtidb-0.8.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL rtidb-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Size 363.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e589fe0829c26e62e5fb972e268bb0f38658561e7613989dc251f5bad5c3bc11
BLAKE2b-256 checksum
How to use checksums
db78d7219ee2d51735a8d67bb49bbad1acd1275b314009a058c34da0aa3913b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Security for rtidb 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.8.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page