Skip to main content

Efficiently cache calls to functions

Project description

cacholote

Efficiently cache calls to functions

Quick Start

>>> import cacholote

>>> from tempfile import TemporaryDirectory
>>> from time import sleep
>>> from timeit import repeat

>>> @cacholote.cacheable
... def cached_func(x):
...     sleep(x)
...     return x

>>> with TemporaryDirectory() as tmpdir, cacholote.config.set(cache_store_directory=tmpdir):
...    timings = repeat(lambda: cached_func(1), number=1, repeat=5)
...    cached_result = cached_func(1)

>>> cached_result
1

>>> [int(t) for t in timings]
[1, 0, 0, 0, 0]

Workflow for developers/contributors

For best experience create a new conda environment (e.g. DEVELOP) with Python 3.10:

conda create -n DEVELOP -c conda-forge python=3.10
conda activate DEVELOP

Before pushing to GitHub, run the following commands:

  1. Update conda environment: make conda-env-update
  2. Install this package: pip install -e .
  3. Sync with the latest template (optional): make template-update
  4. Run quality assurance checks: make qa
  5. Run tests: make unit-tests
  6. Run the static type checker: make type-check
  7. Build the documentation (see Sphinx tutorial): make docs-build

License

Copyright 2019, B-Open Solutions srl.
Copyright 2022, European Union.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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

cacholote-0.1.1.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

cacholote-0.1.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file cacholote-0.1.1.tar.gz.

File metadata

  • Download URL: cacholote-0.1.1.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for cacholote-0.1.1.tar.gz
Algorithm Hash digest
SHA256 226ea1a2ed9e3795737b5ce831fb73f03ade0e5b7c60c8c693f1683aa3ad9598
MD5 dffec3c7d7693756f663b4f4956f702c
BLAKE2b-256 2ed11c818175b503e93b96e5af64e33c0504bc9df94e393d03b1fec1dbf2dbf0

See more details on using hashes here.

File details

Details for the file cacholote-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cacholote-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for cacholote-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b285e6b37d258740517d7f7baae8cc113dc7dc953263e66e4e862e527bc9720f
MD5 d88ef92a87cfd879ba6fd7b197218af5
BLAKE2b-256 c2d98017a453a1b4434a6cbbc0f4c66a6b4e15257c1cddf533dad02dd6157e63

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