--- id: klepto version: "0.2.8" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # klepto — persistent caching to memory, disk, or database License: permissive · Maintenance: active · Downloads: 96.1K/mo ## 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 above — 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 pip install klepto uv add klepto 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_current - Install friction: low - Maintenance: active - Downloads: 96.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags function result caching decorator, persistent cache to disk or database, lru cache alternative, distributed caching archive, function memoization with storage, caching, memoization, distributed-computing [View on SkillFed](https://skillfed.io/packages/klepto) · [View on PyPI](https://pypi.org/project/klepto/)