#35230: Cache ForeignObjectRel.get_accessor_name()
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: nobody
Johnson |
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This method computes the name for the accessor descriptor, used in many
places. Its results are stable, unless the optional `model` parameter is
provided, used only in forms.
Adding a cached property `accessor_name` for the default value can speed
up many code paths. In particular, I profiled the system checks for a
project and found it was taking ~2% of the runtime, which can be basically
eliminated with caching. Results:
Before: 6625 calls taking 2ms
After: 9 calls taking ~0ms
--
Ticket URL: <
https://code.djangoproject.com/ticket/35230>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.