Add a smarter version of Django's @cached_property decorator.
Review Request #8488 — Created Oct. 25, 2016 and submitted
Django's
@cached_property
decorator is very useful for implementing
properties that call expensive methods, as it takes care of all the
caching. Unfortunately, it doesn't behave like a standard property. It
overwrites the documentation and does not retain the name and
attributes. Introspecting the property (such as for documentation
generation purposes) results in some bad information.This introduces a smarter version of
@cached_property
. It's a drop-in
replacement that retains the documentation and attributes, like a normal
decorator would.Unit tests were added to ensure it works correctly, and existing call
sites were updated to use it.
Unit tests pass.
Built some docs and saw that the doc string from the method wrapped by
@cached_property
was showing up instead of the one on
@cached_property
itself.
Description | From | Last Updated |
---|---|---|
Docstring? |
david |
- Change Summary:
-
Added a missing test docstring.
- Commit:
-
274b98488a47e003486e95d45f9917c9f5b1f70ef08abb8d96836bbe7b62a5c73ebcd289c9d38e89