fastshelf
high performance persistent python3 dict with choices of backend
Usage Example
from fastshelf import Shelf
import dbm.gnu
path = "/tmp/shelf1.gnudb"
shelf1 = Shelf(dbm.gnu.open(path,'cf'))
shelf1['a'] = 'A'
shelf1[(1,2,3)] = 'B'
shelf1[144] = {1,2,3,4,12}
print(dict(shelf1))
shelf1.close()
shelf1 = Shelf(dbm.gnu.open(path,'cf'))
print(dict(shelf1))
print(shelf1[(1,2,3)])
import shutil
shutil.rmtree(path)
shelf2 = Shelf(dbm.gnu.open(path,'cf'))
print(shelf2.get("non_existing_key")) # output None
shelf2['a']='A'
print('a' in shelf2) # output True
del shelf2['a']
print('a' in shelf2) # output False
shelf2.update((i,i**2) for i in range(100)) # batch write
print(len(shelf2)) #output 100
print(shelf2[3]) #output 9
Usage
Shelf class of package fastshelf is a dict-like wrapper, that can use any python objects as key and value.
Shelf handles the serialization and deserialization of python objects.
Shelf object initializes with arguments:
- backend: a dbm-like key-value storage database with "bytes" key and value, options include python3's own gnudb, PlyvelDB(via plyvel) and RocksDB(via lbry-rocksdb) or your own bytes-based key/value store
- serializer: a pickle-like serialization library, by default "pickle", which you can replace with dill/msgpack/bson/json
- track_value_changes: if True, enable experimental feature of tracking and writing back value object changes, to maintain similar new style object reference semantics with dict
You can use Shelf like a dict. In addition to standard dict interfaces, batch writes (Shelf.update) can significantly save time.
Metadata
Release files for fastshelf 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastshelf-0.1.4.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastshelf-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / fastshelf-0.1.4.tar.gz
| Download URL | fastshelf-0.1.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fefbf8fb0111cb6755d448a45ebba2f0298f308aac175446d723e39bad0eebe
|
|
BLAKE2b-256 checksum How to use checksums |
082152c6bc23aef36041446d6cee987551726568afaede9cf8bafd548c9c35c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|
Release files / fastshelf-0.1.4-py3-none-any.whl
| Download URL | fastshelf-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9edfeca2fc37c7327f9a5be9956cb5d3dab295f8fad7859d90f950343b14dfd
|
|
BLAKE2b-256 checksum How to use checksums |
a8ff544794379d057da9223092ef89053ce9f7ee13bcd26cb9921cda34f35a62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|