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"
Benchmarks
See benchmark.py.
1. run
continous writes in seconds
| items | lmdb | pysos | sqlitedict | dbm |
|---|---|---|---|---|
| 10 | 0.0160 | 0.0000 | 0.01500 | 0.0160 |
| 100 | 0.0000 | 0.0000 | 0.03100 | 0.0940 |
| 1000 | 0.1090 | 0.0630 | 0.35900 | 1.7310 |
| 10000 | 0.1560 | 0.5770 | 3.80700 | 13.2130 |
| 100000 | 1.4820 | 5.0700 | 23.04100 | 96.0030 |
| 1000000 | 19.2820 | 51.5120 | 212.75400 | 908.4870 |
random reads in seconds
| items | lmdb | pysos | sqlitedict | dbm |
|---|---|---|---|---|
| 10 | 0.0000 | 0.0000 | 0.01500 | 0.0000 |
| 100 | 0.0000 | 0.0000 | 0.07800 | 0.1250 |
| 1000 | 0.0320 | 0.0310 | 1.06100 | 0.3740 |
| 10000 | 0.2340 | 0.3280 | 7.28500 | 2.1220 |
| 100000 | 1.9650 | 3.7910 | 59.67100 | 20.1080 |
| 1000000 | 17.9710 | 40.0460 | 478.33000 | 201.7250 |
2. run
continous write in seconds
| items | lmdb | pysos | sqlitedict | dbm |
|---|---|---|---|---|
| 10 | 0.0000 | 0.0000 | 0.01600 | 0.01600 |
| 100 | 0.0000 | 0.0000 | 0.01600 | 0.09300 |
| 1000 | 0.0320 | 0.0460 | 0.21900 | 0.84200 |
| 10000 | 0.1560 | 2.6210 | 2.09100 | 8.42400 |
| 100000 | 1.5130 | 4.9140 | 20.71700 | 86.86200 |
| 1000000 | 18.1430 | 48.0950 | 208.88600 | 878.16000 |
random reads in seconds
| items | lmdb | pysos | sqlitedict | dbm |
|---|---|---|---|---|
| 10 | 0.0000 | 0.000 | 0.0000 | 0.0000 |
| 100 | 0.0000 | 0.000 | 0.0630 | 0.0150 |
| 1000 | 0.0150 | 0.016 | 0.4990 | 0.1720 |
| 10000 | 0.1720 | 0.250 | 4.2430 | 1.7470 |
| 100000 | 1.7470 | 3.588 | 49.3120 | 18.4240 |
| 1000000 | 17.8150 | 38.454 | 516.3170 | 196.8730 |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lmdbm-0.0.4.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmdbm-0.0.4.tar.gz.
File metadata
- Download URL: lmdbm-0.0.4.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcadb03ee5385f22e8562d8c895eb2adcf0f60f239a30e442e8ca2e855636436
|
|
| MD5 |
906a106ee694e9f3be405fb0cd37fc27
|
|
| BLAKE2b-256 |
05ec78bba2b574dfeb62d571e2f86809a369673490c885d0b5126c4ffbc783fc
|
File details
Details for the file lmdbm-0.0.4-py2.py3-none-any.whl.
File metadata
- Download URL: lmdbm-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a77999cc0d92f1ae1735e7f4f3a6aa50c15bc8bf3678d7906c40dce2734d00d7
|
|
| MD5 |
f8b1fb7da91f2e5c06907c9cc13f1a2d
|
|
| BLAKE2b-256 |
f7a13f9097ce41cffd4f096dbc0f6801f5010beb6d4e230257617936b1c72b52
|