--- id: backports-functools-lru-cache version: "2.0.0" license: unclear license_treatment: permissive maintenance: active --- # backports.functools-lru-cache — Backport of functools.lru_cache License: permissive · Maintenance: active · Downloads: 1.7M/mo ## What it is and what it does This package backports the lru_cache decorator from Python 3.3's functools module, allowing developers to use function result caching via a simple decorator on Python versions that lack it. The decorator caches function results based on input arguments, avoiding redundant computation for repeated calls with the same parameters. The package is designed for compatibility scenarios where code must run on Python versions predating lru_cache's introduction. It follows the standard import-fallback pattern: code attempts to import from the standard library first, then falls back to this backport if unavailable. With zero runtime dependencies and a permissive MIT license, it introduces minimal overhead to any project that includes it. Use it for: - Caching expensive computations (database queries, API calls, mathematical calculations) in long-running applications. - Providing function result caching in libraries that must support multiple Python versions via a single import. - Optimizing recursive algorithms by caching intermediate results to reduce redundant computation. - Reducing redundant I/O operations in utilities that repeatedly call the same function with overlapping parameters. - Ensuring consistent behavior across codebases that target both older and modern Python versions. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides the lru_cache decorator from Python 3.3's functools module for Python environments that lack it natively. Yes, if you need function caching and must support Python versions before 3.2, or if you want a single import pattern across multiple Python versions. However, verify whether your actual minimum Python version truly requires this backport—Python 3.8+ already includes functools.lru_cache natively, making this package redundant for most modern codebases. ## Install pip install backports-functools-lru-cache uv add backports-functools-lru-cache poetry add backports-functools-lru-cache ## Installing backports.functools-lru-cache Before you install: Low install friction with a single pure-Python wheel dependency. Actively maintained as of 2026-04-13 with stable production status. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects. Quickstart: pip install backports.functools-lru-cache try: from functools import lru_cache except ImportError: from backports.functools_lru_cache import lru_cache Requires Python 3.8 or later. Verify before relying: - Whether this backport is still necessary given the stated Python 3.8+ requirement, since functools.lru_cache has been available since Python 3.2. - Specific use cases where the standard library version is unavailable despite meeting the Python 3.8+ minimum. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags lru cache decorator, function memoization, functools backport, least recently used cache, python 3.3 functools, cache decorator import, backport compatibility, caching, compatibility [View on SkillFed](https://skillfed.io/packages/backports-functools-lru-cache) · [View on PyPI](https://pypi.org/project/backports-functools-lru-cache/)