Skip to main content

reckon: Dead simple, dynamic global caching.

Project description

reckon: Dead-simple, dynamic memoization

image image image image image codecov Code style: black

Installation

In order to install the latest version, simply pip3 install -U reckon.

This library requires Python 3.6 or greater.

What is it?

reckon implements a dynamic LRU cache by automatically monitoring the memory usage of your machine and purging entries as it approaches a pre-defined ratio (defaults to 90%).

reckon is largely inspired by the global_lru_cache package, so credit should be given for the initial implementation. This package brings those ideas into python3 and adds a local cache implementation as well.

Usage

Usage is simple:

import reckon

@reckon.memoize
def some_expensive_func(foo: int, bar: int):
    return foo ** bar

reckon will automatically make use of the global cache. If you wish to only maintain a cache local to a function you can simply pass a flag to the decorator:

import reckon

@reckon.memoize(locale="local")
def some_expensive_func(foo: int, bar: int):
    return foo ** bar

While the global cache is automatically maintained, it may be necessary to managed the cache manually. To that purpose, reckon provides the following global methods:

  • reckon.glob.clear: Clear the global cache.
  • reckon.glob.shrink: Shrink the global cache.
  • reckon.glob.usage: Check the current usage ratio.
  • reckon.glob.set_usage: Set the max memory usage ratio for the global cache.

Documentation

Full documentation coming soon!

How to Contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Create a branch on Github for your issue or fork the repository on GitHub to start making your changes to the master branch.
  3. Write a test which shows that the bug was fixed or that the feature works as expected.
  4. Send a pull request and bug the maintainer until it gets merged and published. :)

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

reckon-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

reckon-0.1.0-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file reckon-0.1.0.tar.gz.

File metadata

  • Download URL: reckon-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for reckon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 943d37a63cd241dc71834086abe5c0c10c52f0a8592e47ae747e93693aad546f
MD5 db624674ff4b550c9527d999a20e88a1
BLAKE2b-256 7ed4a25b05e5d034fc63903409e1db34a9a95fa64d0d67c63caf762f790acadc

See more details on using hashes here.

File details

Details for the file reckon-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: reckon-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for reckon-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f116a516a73f62df710346c7ebfe0bd6362a502ea5a95ca0df21dfab9437e64b
MD5 110def4507cfacec07d87b2e3ccc8d74
BLAKE2b-256 bf3c64d15942376092bd7853874dd51f6fb48184549c2202ed8c3b9c61c8ab38

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page