#35745: Improve Documentation on Clearing Cached Property Values
-------------------------------+-----------------------------------------
     Reporter:  Jae Hyuck Sa   |                     Type:  Uncategorized
       Status:  new            |                Component:  Documentation
      Version:  5.1            |                 Severity:  Normal
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+-----------------------------------------
 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
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35745>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070191d52488cd-d50e67cb-8878-48e3-9ffc-26439754dc6b-000000%40eu-central-1.amazonses.com.

Reply via email to