A dictionary-like object that is friendly with multiprocessing and uses key-value databases (e.g., RocksDB) as the underlying storage.
Project description
hugedict
hugedict provides a drop-in replacement for dictionary objects that are too big to fit in memory. hugedict's dictionary-like objects implement typing.Mapping
and typing.MutableMapping
interfaces using key-value databases (e.g., RocksDB) as the underlying storage. Moreover, they are friendly with Python's multiprocessing.
Installation
From PyPI (using pre-built binaries):
pip install hugedict
To compile the source, run: maturin build -r
inside the project directory. You need Rust, Maturin, CMake and CLang (to build Rust-RocksDB).
Features
- Create a mutable mapping backed by RocksDB
from functools import partial
from hugedict.prelude import RocksDBDict, RocksDBOptions
# replace [str, str] for the types of keys and values you want
# as well as deser_key, deser_value, ser_value
mapping: MutableMapping[str, str] = RocksDBDict(
path=dbpath, # path (str) to db file
options=RocksDBOptions(create_if_missing=create_if_missing), # whether to create database if missing, check other options
deser_key=partial(str, encoding="utf-8"), # decode the key from memoryview
deser_value=partial(str, encoding="utf-8"), # decode the value from memoryview
ser_value=str.encode, # encode the value to bytes
readonly=False, # open database in read only mode
secondary_mode=False, # open database in secondary mode
secondary_path=None, # when secondary_mode is True, it's a string pointing to a directory for storing data required to operate in secondary mode
)
-
Load huge data from files into RocksDB in parallel:
from hugedict.prelude import rocksdb_load
. This function creates SST files in parallel, ingests into the db and (optionally) compacts them. -
Cache a function when doing parallel processing
from hugedict.prelude import Parallel
pp = Parallel()
@pp.cache_func("/tmp/test.db")
def heavy_computing(seconds: float):
time.sleep(seconds)
return seconds * 2
output = pp.map(heavy_computing, [0.5, 1, 0.7, 0.3, 0.6], n_processes=3)
- Create dictionary backed by Sqlite:
hugedict.sqlite.SqliteDict
- Chain multiple dictionaries:
hugedict.chained_mapping.ChainedMapping
- Cache a dictionary so previously accessed keys are stored in memory:
hugedict.cachedict.CacheDict
or calledhugedict.types.HugeMapping.cache
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
Built Distributions
File details
Details for the file hugedict-2.14.1.tar.gz
.
File metadata
- Download URL: hugedict-2.14.1.tar.gz
- Upload date:
- Size: 15.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d163f5dfbe11d26746e811c32aae656733f517d56f977e0ac6acc4db1b3e3175 |
|
MD5 | 191a0552bd647b80fe374ba062d74923 |
|
BLAKE2b-256 | adbad94a47db4894b2d1e7b60deebdbc9d1fc7175b61a028f226e88f4d48e706 |
File details
Details for the file hugedict-2.14.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7df654cda2667eeb7a85257c878a572f72f8545420d819516bc65ca7c276f2b |
|
MD5 | ec635ade1dbac7e047129fab40adf432 |
|
BLAKE2b-256 | 27c33a5b42349607e73bfc893c1d1d4336cb7734ca44d29981cc20800f87eadb |
File details
Details for the file hugedict-2.14.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 294bfb73edce5413c356969cb9b20822b2f12b1786811fab159e07410348acce |
|
MD5 | 2f764f9b1d42ffb4671a4a16ab230752 |
|
BLAKE2b-256 | 852196e9c9a38c3e87455f5730b6ddd7f70cdd861952e0b15c1e593401b597a6 |
File details
Details for the file hugedict-2.14.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 243bda2ebf78d8a33786ff2defd0d7b2f3b9ea04539011635ef18951a83bc21a |
|
MD5 | 9c37c828c2e9dda2e69cf8b28f8703f9 |
|
BLAKE2b-256 | 560cddcf3579469ca91a10caab44857cf6863c1a0756f7ec6161ee4afcc9ffc4 |
File details
Details for the file hugedict-2.14.1-cp312-cp312-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp312-cp312-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb3090d7986fc23450d1244efe9b681bcdc309af5b16c2f083e92d64c57cfa62 |
|
MD5 | 19d1122b978b2cefaf52e517017b3da3 |
|
BLAKE2b-256 | 4db835e44aca03f05438a30f3d7c3f03c13974c907016b853c8a800c9f7e6b39 |
File details
Details for the file hugedict-2.14.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e3e257f9987c3ab0cd7c0da57f196717eb97e70dad95594816df0e3d574d59c |
|
MD5 | a014f9080c0c4351f2a64986bfe3715e |
|
BLAKE2b-256 | c07edce145fcfbf9c3aa2a523787ba3b2681b9aa6aba165ef02753af6bb88119 |
File details
Details for the file hugedict-2.14.1-cp312-cp312-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp312-cp312-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.12, macOS 10.14+ universal2 (ARM64, x86-64), macOS 10.14+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af5e6953c0de9539f612e80be4c876ef106d92c8774d0352d55872527edb7b5 |
|
MD5 | 3322fc17bd39263ced97353f59cf70f4 |
|
BLAKE2b-256 | 84282c89716f368e0737ecb37b758bf1c9d83fbadf44c0e64e60ef3926e77246 |
File details
Details for the file hugedict-2.14.1-cp311-cp311-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp311-cp311-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71b6f593ebae49f201c4993dac7179a8f53167cab9659285011e3d7edd70787f |
|
MD5 | 1351b7b6163c245034d1b5460dbc5198 |
|
BLAKE2b-256 | 13c6d31dcbd43e108f2fd2a5c89289f5d6e8d74ebf689be7bc35e22a5af5faed |
File details
Details for the file hugedict-2.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 452937aa4eee5d6d06768917f8fa43191689e910c3e68812cf37d52a4ca2789f |
|
MD5 | ae2c10e2caff3ea742a61719c8a69e68 |
|
BLAKE2b-256 | eda1ac40cd0e500def3b8b5d10b4033382c73e58a47b372b62c3311314209648 |
File details
Details for the file hugedict-2.14.1-cp311-cp311-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp311-cp311-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.11, macOS 10.14+ universal2 (ARM64, x86-64), macOS 10.14+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42d2b63f3d3b97d03b9e7cb12402d5781361bd3cc1917f648df37638e447bb38 |
|
MD5 | 890e94c5dcf44c042c68d7ac77f4d42c |
|
BLAKE2b-256 | 536841b46fc5d22907fc08a0613f2920439cad125d067cc0851d4bd98e9ff0e1 |
File details
Details for the file hugedict-2.14.1-cp310-cp310-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp310-cp310-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a128c3126554e152d379cb86ead1595fcdacbbd2228d2c818bd2b4b39f7d367 |
|
MD5 | 8c4a882ff533844052f9bf4b47c4dde4 |
|
BLAKE2b-256 | 3fd12743007a37be2e17354a0dee3d37f34f564e1336cf915c0a7f81252eccc1 |
File details
Details for the file hugedict-2.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7123ca1231a1717279edfd81b3bbd3feedde372d4611824eea561d24e4d1eb54 |
|
MD5 | 6b9eb9f4fd4bae67e10c25dc6bfd671f |
|
BLAKE2b-256 | ef51bff807fa7c3b5c29f67d9fca106a30a6e4555a1fca4003096f72fe6eca50 |
File details
Details for the file hugedict-2.14.1-cp310-cp310-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp310-cp310-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.10, macOS 10.14+ universal2 (ARM64, x86-64), macOS 10.14+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc85448965a3dd7f625b6ca582f7c7470c4668e5bdc7883f29b74106ebcc66c |
|
MD5 | 7a0614cd468546a80a9e1dc8478e537d |
|
BLAKE2b-256 | a2b3e9e19cc73ea2166f56712a97dd4ab17e2aab7677465c0694fcbdae093e0f |
File details
Details for the file hugedict-2.14.1-cp39-cp39-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp39-cp39-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e5f27e88a5e694d53521f4292128093ba669cc1f9bd191902ae894d7a26552 |
|
MD5 | c753048dcab57dd66250fe971ce6bbe3 |
|
BLAKE2b-256 | 92af62787795f6927df72282acbd8a57f00dcc134463c96aa04e3500ad513c57 |
File details
Details for the file hugedict-2.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b042ccc78edc4573e2e222cb803a7e174f5033052ab45f692005b072bc4f05f3 |
|
MD5 | 28e44358a6e1d07a394b61db297ec152 |
|
BLAKE2b-256 | 5e0a453ea121008d9b6d7b4cfcaab4a8b258414c4cd3770c14ff24d1e3e1ca24 |
File details
Details for the file hugedict-2.14.1-cp39-cp39-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp39-cp39-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.9, macOS 10.14+ universal2 (ARM64, x86-64), macOS 10.14+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f58abdbf06c21033cc0adb72e8c6e890fa98e0382b936b6d49f6cec15bc31579 |
|
MD5 | 6e3cbd4569ed5f02d3d0e0721e3f18c0 |
|
BLAKE2b-256 | 2382049d75069b098d161664e3127f8a161fcfa6ed26fe384fa484bf9bfce307 |
File details
Details for the file hugedict-2.14.1-cp38-none-win_amd64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp38-none-win_amd64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31695862328d25dcf460d9add392880241e7c2c1ec935bb488bbbb06059ec47e |
|
MD5 | 605b8f9eda0225a767d544242a0370bf |
|
BLAKE2b-256 | 2ebcdce9741c92589859b075afc3ba85a9c8a7fee7a473b2d19b34110b3007c4 |
File details
Details for the file hugedict-2.14.1-cp38-cp38-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp38-cp38-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cb94ddc63d7e73a79c22f7585f31941f84fc2be7941517bf0a8543c37cec497 |
|
MD5 | f8ab52852bb0e1df818751b377afda21 |
|
BLAKE2b-256 | b8e6f9b90a87b7ae20815f4314122e05eba357f3f94564cdd4e60af7a8a528fb |
File details
Details for the file hugedict-2.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 527d2c6b357a3c1c4b19b20dedbe0043508bc5cedf504403ed53d53d51276a51 |
|
MD5 | d604a63ee7cd716dd44a10dd3f6b8923 |
|
BLAKE2b-256 | 054751fd73b208c5c97521ce2d52ac4913ae6f0a4a2e1c1179a3a8e624a99633 |
File details
Details for the file hugedict-2.14.1-cp38-cp38-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
.
File metadata
- Download URL: hugedict-2.14.1-cp38-cp38-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.8, macOS 10.14+ universal2 (ARM64, x86-64), macOS 10.14+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81f4f014f21ca4d77d824895ffd894aa2793df1d2179e3d009de9b21a6cca053 |
|
MD5 | d41a7f4c4c3a8dacdb60bce76cc6e890 |
|
BLAKE2b-256 | 8d0db968b50c51d55fe51296f9337234fc551fbffbf1c5e280cafe7becc66982 |