Registry / functools32

functools32

JSON →
library3.2.3-2pypypiunverified

functools32 is a backport of the `functools` standard library module from Python 3.2.3, designed for use with Python 2.7 and PyPy. Its primary purpose is to provide features like `lru_cache` (Least-recently-used cache decorator) to older Python environments that lack them natively. The library saw its last release in July 2015 and is no longer actively maintained, as its features are standard in Python 3+ versions.

pip install functools32
INSTALL
IMPORT
SIG · FUNCTOOLS32
F
functools32
pythonv3.2.3-2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lru_cache
from functools import lru_cache
from functools32 import lru_cache
After installing functools32, its features are intended to be imported directly from the standard `functools` module, as it effectively replaces or augments the built-in module on Python 2.7/PyPy.
partial
from functools import partial
Like lru_cache, other backported features are imported directly from `functools`.

This example demonstrates how to use the `lru_cache` decorator provided by functools32 on Python 2.7. For Python 3 and newer, `lru_cache` is part of the standard `functools` module and `functools32` should not be used.

import sys # This library is only for Python 2.7/PyPy. # For modern Python, functools.lru_cache is built-in. if sys.version_info.major < 3: import functools from functools import lru_cache import time @lru_cache(maxsize=128) def fibonacci(n): if n < 2: return n return fibonacci(n - 1) + fibonacci(n - 2) print(f"Calculating fibonacci(30) on Python {sys.version_info.major}.{sys.version_info.minor}...") start = time.time() result = fibonacci(30) end = time.time() print(f"fibonacci(30) = {result}, took {end - start:.4f} seconds") print(f"Cache info: {fibonacci.cache_info()}") else: print(f"functools32 is not needed on Python {sys.version_info.major}.{sys.version_info.minor}. Use built-in functools.")
Debug
Known issues
breakingfunctools32 is strictly for Python 2.7 and PyPy. Attempting to install or use it on Python 3 will lead to errors, as the functionality it provides is already built into Python 3's standard `functools` module.
fix
Do not install or use functools32 on Python 3. For Python 3, directly `import functools` to access features like `lru_cache`.
affects: Python 3.x
deprecatedThe entire library is considered deprecated due to Python 2.7 reaching its end-of-life and the complete integration of its features into modern Python 3. No further development or maintenance is expected.
fix
Migrate Python 2.7 applications to Python 3, where `functools` provides these features natively and is actively maintained.
affects: All versions
gotchaUsing mutable arguments (e.g., lists, dictionaries) with `lru_cache` will result in a `TypeError: unhashable type` because cached function arguments must be hashable to serve as dictionary keys.
fix
Ensure that all arguments passed to an `lru_cache` decorated function are immutable and hashable. If mutable data must be used, convert it to an immutable representation (e.g., tuple, frozenset) before passing it to the cached function.
affects: All versions (general `lru_cache` behavior)
gotchaWhile `lru_cache` is thread-safe for basic usage, a race condition can occur where the decorated function might be called more than once by different threads if an initial call has not yet completed and cached its result. `cached_property` in newer `functools` also has similar considerations.
fix
For critical scenarios requiring strict single-call execution or for `cached_property` in multi-threaded contexts, implement explicit locking within the decorated function or around the cached property access.
affects: All versions (general `lru_cache` behavior)
Upgrade
Version history
3.2.3-2latest on PyPI · released Jul 11, 2015
Audit
Dependencies
Python 2.7 or PyPyrequiredThe library is a backport specifically for these older Python runtimes and is not intended for Python 3.
Agent activity
2 hits · last 30 days
node
2
Resources
functools32 — pip install functools32 · libregistry