{"id":302,"library":"propcache","title":"propcache","description":"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.","status":"active","version":"0.4.1","language":"python","source_language":"en","source_url":"https://github.com/aio-libs/propcache","tags":["cached_property","performance","Python"],"install":[{"cmd":"pip install propcache","lang":"bash","label":"Install propcache"}],"dependencies":[],"imports":[{"note":"propcache provides an optimized version of cached_property; using functools.cached_property will not leverage these optimizations.","wrong":"from functools import cached_property","symbol":"cached_property","correct":"from propcache import cached_property"},{"note":"under_cached_property is a unique feature of propcache and is not available in functools.","symbol":"under_cached_property","correct":"from propcache import under_cached_property"}],"quickstart":{"code":"from propcache import cached_property\n\nclass MyClass:\n    def __init__(self, value):\n        self._value = value\n\n    @cached_property\n    def computed_property(self):\n        # Expensive computation\n        return self._value * 2\n\nobj = MyClass(10)\nprint(obj.computed_property)  # Outputs: 20","lang":"python","description":"This example demonstrates how to use propcache's cached_property to cache the result of an expensive computation in a class property."},"warnings":[{"fix":"Upgrade to version 0.4.1 or later, where the issue has been resolved.","message":"Version 0.4.0 was yanked due to a reference leak caused by improper reference counting in Cython.","severity":"breaking","affected_versions":"0.4.0"},{"fix":"Ensure that self._cache is correctly initialized and managed within your class when using under_cached_property.","message":"propcache'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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Address pip warnings if necessary, but this is not a library-specific failure.","message":"The 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.","severity":"gotcha","affected_versions":"N/A"}],"env_vars":null,"last_verified":"2026-05-12T12:57:15.130Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Run `pip install propcache` to install the library.","cause":"The propcache library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'propcache'"},{"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.","cause":"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.","error":"AttributeError: cached property is read-only"},{"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.","cause":"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.","error":"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/"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"18.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.6,"disk_size":"19.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"11.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"11.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"17.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}