莉沫酱存储!
做实验的时候经常要存一些数据,用手写with open很麻烦,就想着,啊那不如直接搞一个存硬盘的dict吧!
样例
from rimo_storage import 超dict
d = 超dict('./savedata')
d['x'] = 114514
d['y'] = '好!'
然后下次运行程序的时候就还可以读d里面的内容了。
嗯,就是这么简单!
接口
rimo_storage.超dict(path, compress=None, serialize='json')
基本上就相当于普通的Dict[str, Any]。
其中compress和serialize的类型是Union[str, Tuple[Callable, Callable], None],它的行为是这样——
compress可以选择zlib或者lzma,serialize可以选择json和pickle。- 如果传
Tuple[Callable, Callable],则第一个函数会在写入的时候用,第二个函数会在读取的时候用。 - 如果是
None,则什么都不做。
究竟能存什么东西依赖serialize,如果是json就只能存可json化的东西,如果是pickle就只能存可以pickle的东西(我又在讲废话了)。
rimo_storage.cache.disk_cache(*, path=None, compress=None, serialize='json')
一个装饰器,差不多就是标准库的functools.cache的存硬盘版本,参数的意思和上面一样。
安装
只要使用pip安装就行啦!
pip install rimo-storage
结束
就这样,大家88,我继续回去做实验啦!
Metadata
Release files for rimo-storage 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rimo_storage-1.4.0.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rimo_storage-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / rimo_storage-1.4.0.tar.gz
| Download URL | rimo_storage-1.4.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
caddf2766a733ca93038de2f7b1453a20c6733465f3780dee8ecd39ed8c66565
|
|
BLAKE2b-256 checksum How to use checksums |
08ce53242e3ff427d34a7580393fb9cf67ad25cd10b78df1c6e99c5b30619564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.1
|
Release files / rimo_storage-1.4.0-py3-none-any.whl
| Download URL | rimo_storage-1.4.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fc3978832031b4822dc91b082ae854327b847574c3eff76cd642507fb279cce
|
|
BLAKE2b-256 checksum How to use checksums |
7e0b7cc496a077aacfe9406fbe077577ee80547b33b18b510edf0d24a3ac06b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.1
|