Cache Options.verbose_name_raw
Another candidate for caching, like #35230, following the same system check profiling.
The Model._meta.verbose_name_raw
property returns the stringified version of the verbose_name
attribute whilst temporarily disabling translations. It is only used in django.contrib.auth
for creating permission names.
I found this property was taking ~15% of the total runtime for system checks on a project with 118 models. calls. Turning it into a cached_property
and adding a no-translation fast path saves nearly all this cost, with the below results.
Before: 520 calls taking 10ms
After: 105 calls taking ~0ms
Change History
(6)
Description: |
modified (diff)
|
Owner: |
changed from nobody to Adam Johnson
|
Triage Stage: |
Unreviewed → Accepted
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Description: |
modified (diff)
|
In f25d84f: