Skip to main content

good_cache

good_cache is a Python library that caches the output of your functions. If your function has to read large files as its input or if it has to read files in a directory, and optionally some non-file function parameter values such as a str, int, bool, etc. values then good_cache can remember the input combination and return the ouput to the caller as long as the input combination has been seen (and cached) by good_cache previously.

Here is an article that goes into some detail about good_cache:

Here is the GitHub repo:

Here is the pip command to install it:

pip install good_cache

Here’s a simple example of how you might use good_cache:

from good_cache import fs_files_cache

@fs_files_cache(files='filenames')
def sum_numbers_in_files(filenames):
    result = 0
    for filename in filenames:
        with open(filename, 'rt') as file:
            numbers = list(map(int, file.readlines()))
            result += sum(numbers)
    return result

Here's an example of how you can evict a previous cache for a particular parameter(s)

evicted = sum_numbers_in_files.evict(['a.txt', 'b.txt'])

Metadata

Release files for good-cache 0.1.32

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for good-cache 0.1.32
File Size Uploaded
good_cache-0.1.32.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for good-cache 0.1.32
File Interpreter ABI Platform
good_cache-0.1.32-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / good_cache-0.1.32.tar.gz

Download URL good_cache-0.1.32.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
31d2cf310884297532ac1cddf049b61f71c74b347a61b878a36d05d2b1f0aafe
BLAKE2b-256 checksum
How to use checksums
601cfa1c3636c880be24c8140687e97a4d6eec63aa444759afd99c1e91152c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / good_cache-0.1.32-py3-none-any.whl

Download URL good_cache-0.1.32-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
207dba9fa106d34c9acad4409700524fef853fc433f2ccfc52d885717ff11097
BLAKE2b-256 checksum
How to use checksums
e750ccc575745523ccaac2add56730a26523bae02da8d9bd1f4c12c2f0a5539c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.32 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page