Registry / serialization / propcache

propcache

JSON →
library0.4.1pypypi✓ verified 52d ago

propcache is a Python library that provides accelerated implementations of cached properties, enhancing performance for property caching in Python 3.9 and above. The current version is 0.4.1, with a release cadence that includes regular updates and bug fixes.

serialization
pip install propcache
Install & Compatibility
Where this runs
tested against v0.5.2 · pip install
no network on importno background threads
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.925 runs
installs and imports cleanly · install 0.0s · import 0.012s · 18.3MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.6s · import 0.010s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

cached_property
from propcache import cached_property
from functools import cached_property
propcache provides an optimized version of cached_property; using functools.cached_property will not leverage these optimizations.
under_cached_property
from propcache import under_cached_property
under_cached_property is a unique feature of propcache and is not available in functools.

This example demonstrates how to use propcache's cached_property to cache the result of an expensive computation in a class property.

from propcache import cached_property class MyClass: def __init__(self, value): self._value = value @cached_property def computed_property(self): # Expensive computation return self._value * 2 obj = MyClass(10) print(obj.computed_property) # Outputs: 20
Debug
Known issues
breakingVersion 0.4.0 was yanked due to a reference leak caused by improper reference counting in Cython.
fix
Upgrade to version 0.4.1 or later, where the issue has been resolved.
affects: 0.4.0
gotchapropcache's under_cached_property uses self._cache instead of self.__dict__ to store cached values, which may lead to unexpected behavior if self._cache is not properly managed.
fix
Ensure that self._cache is correctly initialized and managed within your class when using under_cached_property.
affects: All versions
gotchaThe provided test output contains warnings from pip itself regarding running as root and available updates, which are environmental and do not indicate a failure of the library under test. No library-specific failure is described.
fix
Address pip warnings if necessary, but this is not a library-specific failure.
affects: N/A
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'propcache'
The propcache library is not installed in the current Python environment.
fix
Run `pip install propcache` to install the library.
AttributeError: cached property is read-only
You are attempting to directly assign a new value to a property decorated with `propcache.cached_property` or `propcache.under_cached_property`, which are designed to be computed once and then accessed, not directly modified after first access.
fix
If you need to re-evaluate the property, delete the cached attribute from the instance's dictionary (e.g., `del self.__dict__['my_property']`) or the dedicated cache (`del self._cache['my_property']` for `under_cached_property`), and then access the property again. Do not attempt to assign to it directly.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
propcache uses Cython for accelerated implementations, and if pre-built binary wheels are not available for your specific system/Python version, it attempts to compile from source, requiring a C compiler. This specific error occurs on Windows when the necessary build tools are missing.
fix
Install the required C/C++ build tools. On Windows, download and install 'Microsoft C++ Build Tools' from the provided link. On Linux, ensure `gcc` and Python development headers (e.g., `python3-dev` or `python-devel`) are installed. Alternatively, you can force a slower pure-Python installation by running `pip install propcache --config-settings=pure-python=true` or setting the environment variable `PROPCACHE_NO_EXTENSIONS=1` before installation.
Upgrade
Version history
0.5.2latest on PyPI
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
8
seranking-bot
4
ahrefsbot
2
Amazon
1
bingbot
1
bytedance
1
Resources