Cache iterator values to disk using msgpack
Project description
Disk Queue Processing (dqp)
This library makes it easy to serialize Python to disk using msgpack.
The library contains two modules:
dqp.disk_cache
: to easily read/write data to disk and support caching iterators to disk.dqp.disk_queue
: an approach to communicating lists of objects between runs with index/offset metadata.
Example of disk_cache
from typing import Iterator
from dqp.disk_cache import cached_iter
import time
@cached_iter()
def expensive_iter() -> Iterator[int]:
for idx in range(5):
time.sleep(1)
yield idx
def main():
#For replay, drop the cache
expensive_iter.cache_clear()
# First time it takes seconds
for i in expensive_iter():
print(time.asctime(), i)
# Other times the cache is already there
print(time.asctime(), list(expensive_iter()))
print(time.asctime(), list(expensive_iter()))
print(time.asctime(), list(expensive_iter()))
if __name__ == "__main__":
main()
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
dqp-0.1.1.tar.gz
(10.8 kB
view details)
Built Distribution
dqp-0.1.1-py3-none-any.whl
(11.9 kB
view details)
File details
Details for the file dqp-0.1.1.tar.gz
.
File metadata
- Download URL: dqp-0.1.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2166edf00214f9ec9acd7b7caf9e4ce31ad78c72f423155fb18bea0cef3fd96 |
|
MD5 | fa5ec1fdf4e31ce98bb1f0c460002dc7 |
|
BLAKE2b-256 | 5c0ef480e74fa4cc9ce31ff42d794895d3ed2fda0780f4f68076323cccc6d122 |
File details
Details for the file dqp-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: dqp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d5c8ff3dafbfcbbd0d72f7c3a4b74e29ad42cc7d8a517eed151c8893345af78 |
|
MD5 | 4c41249fff0de4fc2bedfa8f45f5383c |
|
BLAKE2b-256 | d9c1816498fb75e6034870fc1a78b3cf6984181eb5b1bfca29b9f0ba5a16d2bc |