Skip to main content

A fast RocksDB wrapper for Python using pybind11.

Project description

PyPI version Python versions

pyrex

Installation

pyrex-rocksdb

A python wrapper for the original (C++) version of RocksDB.

Currently MacOS and Linux wheels are available.

Installation

For linux systems, wheels are provided and can be installed from pypi using:

pip install pyrex-rocksdb

For Windows and MacOS I have built an earlier version of the library. I will re-build once I include certain other important features in the API that are not yet implemented.

Motivation

This library is intended for providing a fast, write-optimized, in-process key value (KV) store in python. Therefore the "big brothers" of the database are the likes of MongoDB and Cassandra. The difference is that you don't need a separate server to run this (hence "in-process") and it is designed to be fairly portable.

RocksDB, which is the underlying storage engine of this database, is an LSM-tree engine. An LSM-tree is different from the ballanced tree index databases (e.g., B-tree/ and B+tree databases). LSM-tree databases offer very high write throughputs and better space efficiency. See more about the motivation for LSM-tree databases (and RocksDB in particular) in this talk.

LSM-tree + SSTable engine basics

To understand where pyrex provides efficiency gains, it is important to understand some basics about the underlying RocksDB engine.

RocksDB and LevelDB are key-value stores with a Log-Structured Merge-tree (LSM-tree) architecture.

The key components of LSM-tree architectures are

  • A MemTable that stores in-memory sorted data
  • A set of Sorted-String tables (SSTables) which are immutable sorted files on disk where data from the MemTable is flushed
  • The process of Compaction, which is a background process that merges the SSTables to remove redundant data and keep read performance high.

In such databases, fast writes create many small, sorted data files called SSTables. To prevent reads from slowing down by checking too many files, a background process called compaction merges these SSTables together. This process organizes the data into levels, where newer, overlapping files sit in Level 0 and are progressively merged into higher levels (Level 1, Level 2, etc.). Each higher level contains larger, non-overlapping files, which ensures that finding a key remains efficient and old data is purged to save space. There are several optimizations and configurations possible for these processes (configurability and "pluggability" are commonly cited RocksDB advantages).

However the main big advantage of RocksDB over LevelDB is its multi-threaded compaction support (LevelDB supports only single threaded compaction, which comes with significant performance limitations). There are several other configurability advantages RocksDB offers over LevelDB. For a more elaborate enumaration of RocksDB advantages please refer to the RocksDB wiki.

Not all are currently supported by the pyrex API, but I'm working on supporting more of them. Feel free to open an issue if there is a feature you want to see (or open a pull request).

Example usage:

Here is a simple example showing the usage of put/get in the DB:

import pyrex
import os
import shutil

DB_PATH = "./test_rocksdb_minimal"

with pyrex.PyRocksDB(DB_PATH) as db:
    db.put(b"my_key", b"my_value")
    retrieved_value = db.get(b"my_key")

print(f"Retrieved: {retrieved_value.decode()}") # Output: Retrieved: my_value

for more examples check the relevant folder and the documentation.

Note on CICD The windows wheels are failing at the moment. The CICD workflow for package builds works and passes all tests only for MacOS and Linux.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_x86_64.whl (14.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (13.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pyrex_rocksdb-0.3.0a0-cp312-cp312-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pyrex_rocksdb-0.3.0a0-cp311-cp311-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ ARM64

pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pyrex_rocksdb-0.3.0a0-cp310-cp310-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ ARM64

pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pyrex_rocksdb-0.3.0a0-cp39-cp39-macosx_14_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7bbde1b23865edd6a617b9d5e511a91c9e907215126b614fcb55db08b27e0feb
MD5 e91f76c9b18413fe52c948b5a8190d9c
BLAKE2b-256 1e99f891fed2111f713d61a966725fca9bd71c55880559ebdaaf4de05db6c187

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8016943227fc85249b74d5798fab3cf305939b055f15db0258c308f36e377efb
MD5 891a3004d7609f0e249e1041bdf99c90
BLAKE2b-256 8d06d9fceb762768df192624b4ad2506d1740e019079d861e89af6c7df8eedbe

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10f99d3aa289c5f8156f64d4faac3743cc67b76e6fa6973f1e7fabf3c49dc0dd
MD5 ad048222806b842bb905a95b3c74b194
BLAKE2b-256 3f2cd877fe38378f5de67d56a096511122c585350bd1e678e9e474b3e48ead3b

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c3665ff7b19268f8ca4413a9ff8d970af186beb28c34ae6eac0d3cfacb52306a
MD5 5c3464b84f42df8c55249a280c83287a
BLAKE2b-256 96fd9df0fd98f8ad9912181c564455f804130b2ea51999674e5b72dc54f76785

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e95ffa51705eb11c8354f4525b943930d99783a5fd8ad43dbfb33ee7f0bff323
MD5 ee1ac0a9e4f51bdf34f9e87720c115fc
BLAKE2b-256 e2c6c30b0e9f3ec2f569a1b7ec3b2387f4d82e3fef6311dbe1a4172a2047eaf3

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 88d976d08e7cf9bb03a25e61b29b16e8671d717e8df1a854004848db67d6f896
MD5 57450ae064c31d679a96585568b95c9d
BLAKE2b-256 971de1f058d94cd76c0a9c9d0a2889bfb20337a85886f7fee4c5ef47e0a04824

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 88721c6d41b897f5c362c323cdc69798a7a8332e2c96ca3f1d2694552839fda3
MD5 2c6bf9de59cc8a28db79b51b51feb687
BLAKE2b-256 58a75b4fa34dc1719977ebc47b962dbb981bca66a67f26b9d7247f995d11a7fb

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 86f21db52c151f002d6a97bcdd2e6e3bd8f05623168aa6f3b757f24c98d2fb50
MD5 ac72bde7b0173ec3dd77dc04b3108530
BLAKE2b-256 a1775860cbc86038afad46bcc42986e709807166d696e62532942ba664297cd3

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54202ab10be76a05debac8787b8e89db52bc2b2b1b69f374da4d3a5b84736842
MD5 60bf6f559fdf66d619399b57a6ee245c
BLAKE2b-256 14afade9a57857500f86027ec81024f162ea26365a75bcce9cc03693f300f2db

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 31e7f7e33ae92445ea7c706ba84ca7c0b9f882468495feefc33b57ff0a72dd91
MD5 60f89283dd1665b71a5f23f89623713f
BLAKE2b-256 1adade754a34f6230919f1075ed188b785b9ed215d89d5c7adaed3de8359173e

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1597a8649087374b66285400a708ccbe50247f55f020ec192b172432c9a38fd3
MD5 dea43586265988dfcfd4e9e88a22d1ff
BLAKE2b-256 3106cdc9730a74c6df29da8f8f7b92dd15094a3d011f3edcac827961b8292924

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fbb33ba2db640b6170a5ca0bc305172ac9e4e989cfcc30f33b86e98663c1ae70
MD5 8881f14ef8a3f5c77bc30b73e0df6bb9
BLAKE2b-256 4c6f3b4e90e8ffb4fe0296cd1fd48ce5abfb029515d78720d9b636e6654345a5

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d53ec49058df482431f5fa3dceebc1cbee688d99055c448a10f03d6909b9d31
MD5 0975d4b73e7311b75b7d1d5d4440d6f9
BLAKE2b-256 06f3118a00c3803db7123cdc32e47a0c29db5d80a8c8dedc657eb71041588ae6

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2b0c854cbaebbb4b90e8bfe92a147e94828048f7842514418ca54e104f581539
MD5 03b2756856649256242f15a932ebb3c9
BLAKE2b-256 54dd8cd7e3bea708296b52dfff25746aee2601d8b50932ad61843585e55df54e

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fa7a252055cd8f7870117a409c7a51a7d499a44c343ff82432904f21a4a53d1f
MD5 fa5a8b50911621722ba77812863e3377
BLAKE2b-256 a68db7d27b4b84f9db8336263c080e8ff215dc0b2384da6d2287ae59eaeb0626

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4de3c628817af8e1d3797e9b380f735f82e68176c152fa7cf606838bacdf0b7d
MD5 339e46a38edda7ee6e21e92d4c50e7ea
BLAKE2b-256 e1b61e78ddd0d125fac5b6aa99de1fb0791fa26dce9f735895a276219ccb25f7

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp39-cp39-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2c92194b08a684730e1f62b33871083794cbfbda165d8e3077af5bcbba001af4
MD5 84e5867158b10c4b136908181b654c3f
BLAKE2b-256 36b2972f6e4af2ddc08ce5b9daf8db9f7def4dc2ff6f74073403c71d9000e86c

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80b978ddd7ffd679d9e80d6a272577227c96cb99faf3c78851bb548b352de0ca
MD5 f6527fb5cc438bd3024db39397fadb13
BLAKE2b-256 69d847a83f6a2c7dc1457858f9efbd65cea12fb772c10c06c55b64c95989a396

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp39-cp39-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd5fb34924e3b36100e2d7779f7a21d07704fb867beb2681a844815e219b3697
MD5 28a72b1407666009a00dd9d5c742a47a
BLAKE2b-256 b2e141af96fc5b44c38af76c8f048afc8e74ce93ef87c47b63aa4635fe2a4d26

See more details on using hashes here.

File details

Details for the file pyrex_rocksdb-0.3.0a0-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrex_rocksdb-0.3.0a0-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 11aec0804bc57d9c0fd8108f01699607264c929861b31e18732c7a15d0a834f7
MD5 79b0359d2ae5e112f77756ac3067c7c6
BLAKE2b-256 4db1e1be02f6785f8ce4fb9f5da8737f29bc975216e42bc06fc26dbfa5602bc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page