#35745: Improve Documentation on Clearing Cached Property Values
-------------------------------+-----------------------------------------
Reporter: Jae Hyuck Sa | Owner: Jae Hyuck Sa
Type: Uncategorized | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Description changed by Jae Hyuck Sa :
Old description:
> The process of clearing cached values from Django's cached_property is
> currently undocumented, even though it is a pattern used extensively
> throughout the codebase. Developers may not be aware of the best
> practices for resetting cached properties and might attempt to implement
> custom methods unnecessarily.
>
> After receiving feedback on a related feature proposal, I now understand
> that Django will eventually transition to using Python's
> functools.cached_property once support for Python 3.11 is dropped (see
> #30949). Therefore, adding a method for clearing the cache directly to
> cached_property might not be the best course of action. Instead,
> improving the documentation will ensure developers are aware of the
> correct method for clearing cached values. The recommended pattern for
> clearing cached values is:
>
> This pattern is used extensively in the codebase, as seen in the
> following search results: GitHub Search
> Results(https://github.com/search?q=repo%3Adjango%2Fdjango+%22__dict__.pop%22&type=code).
>
> Related feature discussion: #35743
> Consensus on moving to functools.cached_property: #30949
New description:
The process of clearing cached values from Django's cached_property is
currently undocumented, even though it is a pattern used extensively
throughout the codebase. Developers may not be aware of the best practices
for resetting cached properties and might attempt to implement custom
methods unnecessarily.
After receiving feedback on a related feature proposal, I now understand
that Django will eventually transition to using Python's
functools.cached_property once support for Python 3.11 is dropped (see
#30949). Therefore, adding a method for clearing the cache directly to
cached_property might not be the best course of action. Instead, improving
the documentation will ensure developers are aware of the correct method
for clearing cached values. The recommended pattern for clearing cached
values is:
This pattern is used extensively in the codebase, as seen in the following
search results: GitHub Search
Results(https://github.com/search?q=repo%3Adjango%2Fdjango+%22__dict__.pop%22&type=code).
Related feature discussion: #35743
Consensus on moving to functools.cached_property: #30949
Feedback and suggestions from the community are greatly appreciated!
--
--
Ticket URL: <https://code.djangoproject.com/ticket/35745#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070191d5256553-580f9e8c-d226-4ff2-8db7-72ec8992a280-000000%40eu-central-1.amazonses.com.