A simple numpy caching library
Project description
Pyache
Python numpy caching library
This library caches numpy data that is generated from files and saves them in chunks to the disk. This is useful any time a computationally expensive task is done to files to transform them into a form needed in memory.
Usage
Create a Pycache
object and call load
with your filenames.
import numpy as np
from time import sleep
from pyache import Pyache
def load_file(filename) -> np.ndarray:
print('Processing {}...'.format(filename))
sleep(0.5)
return np.ones([100])
pyache = Pyache('.cache', load_file, 'ones-processor')
data = pyache.load(
['thing-1.png', 'thing-2.png', 'thing-3.png'],
on_gen=lambda x: print('Just reprocessed', x),
on_loop=lambda: print('Loaded one more...')
) # Takes 1.5 seconds
# ... Run a second time (or program re-run):
data = pyache.load(
['thing-1.png', 'thing-2.png', 'thing-3.png']
) # Takes 0.0 seconds
data = pyache.load(
['thing-1.png', 'thing-2.png', 'thing-3.png', 'thing-4.png']
) # Takes 0.5 seconds
Installation
pip install pyache
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyache-0.2.0.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file pyache-0.2.0.tar.gz
.
File metadata
- Download URL: pyache-0.2.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bff0e7fecd0332d09cdd4a795a02139143011302fd22608b07ff101a1b11ae2 |
|
MD5 | 3dc1317d5b67313a4e0a56dfbe22a7b6 |
|
BLAKE2b-256 | 8fc0ef5fcdaed2d56f053cbe250f83000149cffec67fe8eebba7df94ab1b9954 |
File details
Details for the file pyache-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: pyache-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea8df1959166b99ff9da0c8220f17202a23766d5c2f743da2fb1366489152e39 |
|
MD5 | 91982f9bec7bb8f849e25ee7a0e5195d |
|
BLAKE2b-256 | 4ce13f9ff31fce888bd46e6caa15e4c5b8277a44b8e69df98f11e5f650ea174a |