Skip to main content

A dictionary-like object that is friendly with multiprocessing and uses key-value databases (e.g., RocksDB) as the underlying storage.

Project description

hugedict PyPI Documentation

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

  1. 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
)
  1. 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.

  2. 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)
  1. Create dictionary backed by Sqlite: hugedict.sqlite.SqliteDict
  2. Chain multiple dictionaries: hugedict.chained_mapping.ChainedMapping
  3. Cache a dictionary so previously accessed keys are stored in memory: hugedict.cachedict.CacheDict or called hugedict.types.HugeMapping.cache

Project details


Download files

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

Source Distribution

hugedict-2.14.5.tar.gz (15.4 MB view details)

Uploaded Source

Built Distributions

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

hugedict-2.14.5-cp313-cp313-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp313-cp313-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.13macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

hugedict-2.14.5-cp312-cp312-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp312-cp312-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.12macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

hugedict-2.14.5-cp311-cp311-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp311-cp311-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.11macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

hugedict-2.14.5-cp310-cp310-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp310-cp310-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.10macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

hugedict-2.14.5-cp39-cp39-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp39-cp39-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.9macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

hugedict-2.14.5-cp38-cp38-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.8Windows x86-64

hugedict-2.14.5-cp38-cp38-manylinux_2_35_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.35+ x86-64

hugedict-2.14.5-cp38-cp38-manylinux_2_34_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

hugedict-2.14.5-cp38-cp38-manylinux_2_34_aarch64.whl (5.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ ARM64

hugedict-2.14.5-cp38-cp38-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl (8.9 MB view details)

Uploaded CPython 3.8macOS 10.14+ universal2 (ARM64, x86-64)macOS 10.14+ x86-64macOS 11.0+ ARM64

File details

Details for the file hugedict-2.14.5.tar.gz.

File metadata

  • Download URL: hugedict-2.14.5.tar.gz
  • Upload date:
  • Size: 15.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hugedict-2.14.5.tar.gz
Algorithm Hash digest
SHA256 df510be8e73cd74742b1a11aae3e42ae2058f3eda40f7baada7cf5891ddf067c
MD5 135c148a79a8be3d7d9b25f82903751e
BLAKE2b-256 94b23db11bcb74a995964ecebac4d3d76b99d6911997c8568fbf273a3721a5d2

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 cbd82cd9d42b8c304acf953ab51f94b5c7d289b8b2ca821555c5a4339b49e27d
MD5 b80a70be959c17db06286d30a1b7150c
BLAKE2b-256 d1f452d7d04aaef8b388e00237adf2a43ac76c6d89ce8b864bf317793421d9dc

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp313-cp313-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp313-cp313-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 0788db03528e7efef8242fe12e712d369c6109a93892a0f969c1bc83ac5992d8
MD5 7baedf31f5ba438a1c3e272147430055
BLAKE2b-256 6e4bd694ec1dd03fff2c31f7f0543d0f21390a5580b8a8736acdc394bea8c916

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 0ee72ba0a5b1e12943365e4940ffcb858384e36ddefb6b019b01ec8f1fdeccf2
MD5 f53b3712bfb36d7aa2849b1371667b47
BLAKE2b-256 676b6d364420e59538c4c8fb70e490f76b5b5dc2e6bc33ed0d63e7641a2f6734

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp312-cp312-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp312-cp312-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 e7b4c02e94da6adcfaf159af48c876badcac009ce05307e077da1e721504626d
MD5 b32bf831c22163aacff37262a3c9d625
BLAKE2b-256 bcfc674a034ec1c98ec9bf4be56f2505e8fb0106e675e7242b3c65166d5267f5

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp311-cp311-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 bca7c3025258256cef6b8ab897fd44c7be92afa7666854f28121bc79ec5d5c45
MD5 7c806d75c1a2fb9806b373f60c49a0a0
BLAKE2b-256 0cfb237c4422efa7250b15e2690a7c30742b77ebc5e20df6286ca9b103bb662e

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp311-cp311-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp311-cp311-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 777a5c7e86c07ff89d190e5aeb713e21df4b351bed96a2247c6c1435a4e26e7c
MD5 c9319dbfbd7a2210a705e4a7783713e9
BLAKE2b-256 741dbf96045a91c125bf49057f6d4c0689fab7ae292b5938c284dc704d0d2a20

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d4f6623554c1cd013190ec208dcb4014c4364175f6b2a945b8fd2c884c1566b6
MD5 43260bb8f2e2c7c260ec0fa18f6bb4be
BLAKE2b-256 55a67bf696c707f79188210cdbb64fea6e83e25532c5b79bb2f6850f85d660ef

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp310-cp310-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp310-cp310-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 23cb1e813f5e64d08857a39c95dd61ce8f4bf7ce9d05413b6eefa3061c774865
MD5 d2749deef2282ec7d4e218cf00429d84
BLAKE2b-256 877ecb758fd93134434b39b442f1723d5cf29066c4a66816241116d46c9be2d0

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 72c1d6124fb86af80eb9d59a09d4bf453fac2da971d31f89dda0c621451478f6
MD5 62994eb7f4b70dc22eb3bd4a6eb79888
BLAKE2b-256 ee727b42327a0d5c10eb5c9678e2643e544bd035da35d60b92bd505e704a5995

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp39-cp39-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp39-cp39-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 52f2368edfaaeb57c831b9512f9451e5b388743ac704c9ad320a73e68425a6ea
MD5 1caa89a9cdd9f964a403cfd85928247b
BLAKE2b-256 b1fc27d3fe601d7e25e0bf2eb03d202300df5bbcbb6a2a248ef141cf5f2e5dd6

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: hugedict-2.14.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hugedict-2.14.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0ba5eff7f7847657b6be1fb40035e4581e288b2ab884d712a2b23bb90294635a
MD5 3a333bc727333914eb10fae4bc2ed3a3
BLAKE2b-256 69ed887894c748f360b988ebaef5665654d98f9b7285abb46c18680b15665117

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp38-cp38-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp38-cp38-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 0951dbf987536e67e167d9860b0456c076791dfe0db0c61ead63560def2258aa
MD5 dce0467abbfc3a1364de3f15624f36f9
BLAKE2b-256 e5e450d4cc15282106dd1a90901d324dc802b18e4389519ecceaf92e96434d7f

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4d51309fdd273e6bd4ff4f0ff055eafb89b976613098302130fcd979aeaad30d
MD5 796ac9a1c0437bb4b33646fc9387866e
BLAKE2b-256 231735e6479dd65ae22094498239214a3a21acbc7da703df9f015121ce7798c3

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp38-cp38-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp38-cp38-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7b007b9f5d0aadf4ef3674ab8f86f2b0c34d532facd9d0d95f9c5931f305e44d
MD5 889107f503cb765f67306347e395a365
BLAKE2b-256 66d9abc732ceaa16c75e2df8b1ef6cdc8ef124fcd423d392b6c41908b8e3fc51

See more details on using hashes here.

File details

Details for the file hugedict-2.14.5-cp38-cp38-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for hugedict-2.14.5-cp38-cp38-macosx_10_14_x86_64.macosx_11_0_arm64.macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 22b939301ac81f4e820f98cf3c73868715dae7cc15a03a1e73f4879e13201cc9
MD5 ff967a53ef4e221a37cb290437cd8fb2
BLAKE2b-256 6d2d2500b718bd37bb5323dc089f7b4b52c1acd2a50dbbc0a322ac249798e025

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