1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
lmdbm
This is a Python DBM interface style wrapper around LMDB (Lightning Memory-Mapped Database).
It uses the existing lower level Python bindings py-lmdb.
This is especially useful on Windows, where otherwise dbm.dumb is the default dbm database.
Install
pip install lmdbm
Example
from lmdbm import Lmdb
with Lmdb.open("test.db", "c") as db:
db[b"key"] = b"value"
db.update({b"key1": b"value1", b"key2": b"value2"}) # batch insert, uses a single transaction
Use inheritance to store Python objects using json serialization
import json
from lmdbm import Lmdb
class JsonLmdb(Lmdb):
def _pre_key(self, value):
return value.encode("utf-8")
def _post_key(self, value):
return value.decode("utf-8")
def _pre_value(self, value):
return json.dumps(value).encode("utf-8")
def _post_value(self, value):
return json.loads(value.decode("utf-8"))
with JsonLmdb.open("test.db", "c") as db:
db["key"] = {"some": "object"}
obj = db["key"]
print(obj["some"]) # prints "object"
Warning
As of lmdb==1.2.1 the docs say that calling lmdb.Environment.set_mapsize from multiple processes "may cause catastrophic loss of data". If lmdbm is used in write mode from multiple processes, set autogrow=False and map_size to a large enough value: Lmdb.open(..., map_size=2**30, autogrow=False).
Benchmarks
See benchmark.py and requirements-bench.txt. Other storage engines which could be tested: wiredtiger, berkeleydb.
Storage engines not benchmarked:
- tinydb (because it doesn't have built-in str/bytes keys)
continuous writes in seconds (best of 3)
| items | lmdbm | lmdbm-batch | pysos | sqlitedict | sqlitedict-batch | dbm.dumb | semidbm | vedis | vedis-batch | unqlite | unqlite-batch |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 10 | 0.000 | 0.015 | 0.000 | 0.031 | 0.000 | 0.016 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 100 | 0.094 | 0.000 | 0.000 | 0.265 | 0.016 | 0.188 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 1000 | 1.684 | 0.016 | 0.015 | 3.885 | 0.124 | 2.387 | 0.016 | 0.015 | 0.015 | 0.016 | 0.000 |
| 10000 | 16.895 | 0.093 | 0.265 | 45.334 | 1.326 | 25.350 | 0.156 | 0.093 | 0.094 | 0.094 | 0.093 |
| 100000 | 227.106 | 1.030 | 2.698 | 461.638 | 12.964 | 238.400 | 1.623 | 1.388 | 1.467 | 1.466 | 1.357 |
| 1000000 | 3482.520 | 13.104 | 27.815 | 5851.239 | 133.396 | 2432.945 | 16.411 | 15.693 | 15.709 | 14.508 | 14.103 |
random reads in seconds (best of 3)
| items | lmdbm | lmdbm-batch | pysos | sqlitedict | sqlitedict-batch | dbm.dumb | semidbm | vedis | vedis-batch | unqlite | unqlite-batch |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 10 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | ||||
| 100 | 0.000 | 0.000 | 0.031 | 0.000 | 0.000 | 0.000 | 0.000 | ||||
| 1000 | 0.016 | 0.015 | 0.250 | 0.109 | 0.016 | 0.015 | 0.000 | ||||
| 10000 | 0.109 | 0.156 | 2.558 | 1.123 | 0.171 | 0.109 | 0.109 | ||||
| 100000 | 1.014 | 2.137 | 27.769 | 11.419 | 2.090 | 1.170 | 1.170 | ||||
| 1000000 | 10.390 | 24.258 | 447.613 | 870.580 | 22.838 | 214.486 | 211.319 |
Metadata
Release files for lmdbm 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lmdbm-0.0.5.tar.gz | 5.4 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lmdbm-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
| lmdbm-0.0.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / lmdbm-0.0.5.tar.gz
| Download URL | lmdbm-0.0.5.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4b6a2c0700d7d3e3c09f902c63a4fb3356662d171ce92bdde0803e02e25c859
|
|
BLAKE2b-256 checksum How to use checksums |
67c61d45cef3061b555660b3f326582be15d7351a6e84b9183bc0ff15decf154
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / lmdbm-0.0.5-py3-none-any.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | lmdbm-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48a49dfc0115612d72c2918c65213c04e7c8871cd2714288ebcdd5817281999e
|
|
BLAKE2b-256 checksum How to use checksums |
bfcf4212bfc908d99b7bd0e2de45817209faa88b1dea5b0312c47fc09c34f33b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / lmdbm-0.0.5-py2.py3-none-any.whl
| Download URL | lmdbm-0.0.5-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ddc91f3d774eddab296629dd542a03298d758e25bd2b1c8c2ddb5314ba383e19
|
|
BLAKE2b-256 checksum How to use checksums |
d335c3341699f9575128537219e7428aadd2ceeb7971fc9533ccfaab5f321b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|