### Install propcache Source: https://github.com/aio-libs/propcache/blob/master/README.rst Install the propcache library using pip. This command installs the default version, which may include compiled extensions. ```bash $ pip install propcache ``` -------------------------------- ### Install propcache (Pure Python) Source: https://github.com/aio-libs/propcache/blob/master/README.rst Install the pure-Python version of propcache by setting the --config-settings=pure-python=false option. This bypasses compilation and is useful when C compilers or Python headers are unavailable. ```bash $ pip install propcache --config-settings=pure-python=false ``` -------------------------------- ### Install Dev Dependencies and Run Tests Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Installs development dependencies and builds the Cython extension in place. Then, it runs the test suite using pytest. This is the primary command for local development testing. ```bash make .develop pytest ./tests ``` -------------------------------- ### Example CHANGES Fragment Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md This is an example of a CHANGES fragment written in reStructuredText. It should use past tense and be signed with the contributor's handle. ```rst Started shipping reproducible wheels by injecting ``-ffile-prefix-map`` into the default tmp-dir build -- by :user:`github-handle`. ``` -------------------------------- ### Example reStructuredText Change Note (Bugfix) Source: https://github.com/aio-libs/propcache/blob/master/CHANGES/README.rst This is an example of a change note fragment for a bugfix, specifying the architecture for Windows wheels and including the author's username. ```rst Started shipping Windows wheels for the x86 architecture -- by :user:`Dreamsorcerer`. ``` -------------------------------- ### Example reStructuredText Change Note (Removal) Source: https://github.com/aio-libs/propcache/blob/master/CHANGES/README.rst This is an example of a change note fragment for a removal, following the reStructuredText format and including the author's username. ```rst Dropped Python 3.5 support; Python 3.6 is the minimal supported Python version -- by :user:`webknjaz`. ``` -------------------------------- ### Example reStructuredText Change Note (Feature) Source: https://github.com/aio-libs/propcache/blob/master/CHANGES/README.rst This is an example of a change note fragment for a new feature, detailing added support for GenericAliases in Python 3.9+ and including the author's username. ```rst Added support for ``GenericAliases`` (``MultiDict[str]``) under Python 3.9 and higher -- by :user:`mjpieters`. ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/aio-libs/propcache/blob/master/docs/contributing/guidelines.md Execute this command to build the documentation website locally using Sphinx. ```shell $ make doc ``` -------------------------------- ### Build Project In-Place Source: https://github.com/aio-libs/propcache/blob/master/docs/changes.md Use this command to build the project in-tree. This setting affects wheels and is enabled by default for temporary directory builds. ```console $ python -m build --config-setting=build-inplace=true ``` -------------------------------- ### Commit Version and Changelog Changes Source: https://github.com/aio-libs/propcache/blob/master/docs/contributing/release_guide.md Commit the updated propcache/__init__.py file, the generated changelog, and removed fragments. ```shell [dir:propcache] $ git commit -v CHANGES{.rst,/} propcache/__init__.py ``` -------------------------------- ### Run Docs Spell Check Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Execute the `make doc-spelling` command before pushing to ensure all technical terms are correctly spelled and added to the wordlist if necessary. This prevents CI failures. ```bash make doc-spelling ``` -------------------------------- ### Create Draft Pull Request Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Use the GitHub CLI to create a pull request as a draft. This ensures the PR is reviewed before being marked as ready. ```bash gh pr create --draft ``` -------------------------------- ### Makefile Targets for Testing Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Provides alternative Makefile targets for various testing scenarios. 'make test' runs linting and pytest, 'make cov' adds coverage reporting, 'make vtest' provides verbose output, and 'make fmt' runs pre-commit hooks for code formatting. ```bash make test ``` ```bash make cov ``` ```bash make vtest ``` ```bash make fmt ``` -------------------------------- ### Build Changelog with Towncrier Source: https://github.com/aio-libs/propcache/blob/master/docs/contributing/release_guide.md Use Towncrier to build the changelog from fragments. Ensure the version number does not have a leading 'v' and follows PEP 440. ```shell [dir:propcache] $ python -m towncrier build \ -- --version 'VERSION_WITHOUT_LEADING_V' ``` -------------------------------- ### Control build-inplace setting Source: https://github.com/aio-libs/propcache/blob/master/CHANGES.rst Use this setting to control whether the project builds in-tree or in a temporary directory. It only affects wheels and defaults to building in a temporary directory. ```console $ python -m build --config-setting=build-inplace=true ``` -------------------------------- ### Create Symlink for CHANGES Fragment Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md When both an issue and a PR number are relevant, create a symlink for the PR number pointing to the issue-numbered fragment. ```bash ln -s 68.packaging.rst CHANGES/218.packaging.rst ``` -------------------------------- ### Push Release Tag Source: https://github.com/aio-libs/propcache/blob/master/docs/contributing/release_guide.md Push the newly created Git tag to the upstream repository. ```shell [dir:propcache] $ git push origin 'VERSION_WITH_LEADING_V' ``` -------------------------------- ### Tag Release Commit Source: https://github.com/aio-libs/propcache/blob/master/docs/contributing/release_guide.md Create a GPG-signed Git tag for the release. The tag name should be prefixed with 'v' and include a message describing the release contents. ```shell [dir:propcache] $ git tag \ -s 'VERSION_WITH_LEADING_V' \ -m 'VERSION_WITH_LEADING_V' \ -m 'This release does X and Y.' ``` -------------------------------- ### Agent Run Details in Collapsed Block Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Place agent output, such as test and lint results, in a collapsed `
` block at the very bottom of the PR body. This keeps the main PR summary readable. ```html
Agent run details (optional, for reviewers) Tests: Lint:
``` -------------------------------- ### AIO-Libs Pull Request Template Structure Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Use this markdown structure verbatim for your pull request body. Ensure all sections are filled out appropriately. ```markdown ## What do these changes do? ## Are there changes in behavior for the user? ## Related issue number Fixes #NNNN ## Checklist - [x] I think the code is well written - [x] Unit tests for the changes exist - [x] Documentation reflects the changes - [x] Add a new news fragment into the `CHANGES/` folder ``` -------------------------------- ### cached_property Source: https://github.com/aio-libs/propcache/blob/master/docs/api.md This decorator functions exactly the same as the standard library `cached_property()` decorator, but it’s available in the `propcache.api` module along with an accelerated Cython version. The cached value is stored in the instance’s `__dict__` dictionary. ```APIDOC ## @propcache.api.cached_property(func) ### Description This decorator caches the result of a function on an instance. The cached value is stored in the instance's `__dict__`. ### Usage ```python from propcache.api import cached_property class MyClass: @cached_property def my_cached_attribute(self): # This operation will only be performed once return expensive_computation() ``` ### Clearing the Cache To clear a cached value, you can use the `del` operator on the instance’s attribute or call `instance.__dict__.pop('attribute_name', None)`. ``` -------------------------------- ### Use under_cached_property Decorator Source: https://github.com/aio-libs/propcache/blob/master/docs/api.md Use this decorator to cache a method's return value as a private attribute. The cache is stored in the instance's _cache dictionary, separate from __dict__. Call instance.clear_cache() to invalidate the cached value. ```python from propcache.api import under_cached_property class MyClass: def __init__(self, data: List[float]): self._data = data self._cache = {} @under_cached_property def calculated_data(self): return expensive_operation(self._data) def clear_cache(self): self._cache.clear() instance = MyClass([1.0, 2.0, 3.0]) print(instance.calculated_data) # expensive operation instance.clear_cache() print(instance.calculated_data) # expensive operation ``` -------------------------------- ### under_cached_property Source: https://github.com/aio-libs/propcache/blob/master/docs/api.md Transform a method of a class into a property whose value is computed only once and then cached as a private attribute. Similar to the `cached_property()` decorator, but the cached value is stored in the instance’s `_cache` dictionary instead of `__dict__`. ```APIDOC ## @propcache.api.under_cached_property(func) ### Description This decorator caches the result of a method on an instance, storing the cached value in the instance's `_cache` dictionary. This is useful for methods that perform expensive computations and should only be run once per instance. ### Usage ```python from typing import List # Assume expensive_operation is defined elsewhere def expensive_operation(data: List[float]) -> float: # Simulate an expensive computation return sum(data) * 2 class MyClass: def __init__(self, data: List[float]): self._data = data self._cache = {} @under_cached_property def calculated_data(self): print("Performing expensive operation...") return expensive_operation(self._data) def clear_cache(self): self._cache.clear() instance = MyClass([1.0, 2.0, 3.0]) print(instance.calculated_data) # expensive operation is performed print(instance.calculated_data) # cached value is returned instance.clear_cache() print(instance.calculated_data) # expensive operation is performed again ``` ### Clearing the Cache To clear the cached value, call the `clear_cache` method on the instance, which internally calls `self._cache.clear()`. ``` -------------------------------- ### Disclose Agent in PR Body Source: https://github.com/aio-libs/propcache/blob/master/AGENTS.md Include a single line at the bottom of the PR body to name the agent that drafted the change. This is a mandatory disclosure. ```markdown Drafted with ; reviewed by . ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.