skillfed

klepto

persistent caching to memory, disk, or database

klepto v0.2.8 96.1K downloads/30d#13,232 on PyPI277
Permissive license BSD-3-Clause Active released

What it is and what it does

klepto extends Python's standard caching with multiple replacement strategies and persistent storage backends. It provides LRU, LFU, MRU, and random-replacement caching algorithms, each available in standard and "safe" variants that recover from hashing errors. Beyond in-memory caching, klepto archives function results to files, SQL databases, or HDF5 files using a dictionary-style interface, enabling cache reuse across interpreter sessions.

The package is designed for distributed and parallel computing where caches need to be shared across threads and processes. It uses keymaps to convert function arguments into cache keys, supporting raw objects, hashes, strings, or serialized forms. klepto depends on dill for serialization and pox for utilities, and is part of the larger pathos framework for heterogeneous computing.

Use it for:

  • Cache expensive computations across multiple Python sessions by saving results to disk or database
  • Decorate functions in distributed workflows where multiple workers need access to the same cached results
  • Implement custom caching strategies (LFU, MRU) instead of only LRU for domain-specific performance tuning
  • Archive function call results to SQL or HDF5 for long-term storage and analysis
  • Build fault-tolerant parallel applications that can recover cached state after restart

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

klepto provides multiple caching algorithms (LRU, LFU, MRU, random-replacement) and persistent archiving to files, databases, or HDF5, with a dictionary-style interface and function decorator support.

Yes. klepto is actively maintained, has low install friction, carries a permissive license, and fills a genuine gap for persistent, multi-algorithm caching in distributed settings. It's stable (Production/Stable status) with no known vulnerabilities. Install it if you need caching beyond functools.lru_cache or persistent result archiving; skip it if simple in-memory caching suffices.

Install

klepto on PyPI

pip

pip install klepto

uv

uv add klepto

poetry

poetry add klepto

Installing klepto

Before you install

Low friction install with only two runtime dependencies (pox and dill). Actively maintained with recent commits and stable production status.

License in practice

BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; attribution and license notice required.

Quickstart

pip install klepto

from klepto.caches import lru_cache

@lru_cache()
def expensive_function(x):
    return x ** 2

result = expensive_function(5)

Requires Python >=3.9; optional backends (HDF5, SQL) require additional dependencies.

Verify before relying

  • Performance characteristics compared to functools.lru_cache for typical workloads
  • Thread/process safety guarantees for concurrent access to persisted caches
  • Serialization overhead when using different keymaps (hashmap, picklemap, stringmap)

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pox, dill
Maintenance actively maintained — 207 days since the last release
Last repo commit
First released
Downloads 96,083/month — #13,232 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: klepto-0.2.8-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Scientific/EngineeringTopic :: Software Development

Tags

function result caching decoratorpersistent cache to disk or databaselru cache alternativedistributed caching archivefunction memoization with storage
cachingmemoizationdistributed-computing

More Software Development packages