#35241: Cache Model._meta.get_parent_list() -------------------------------------+------------------------------------- Reporter: Adam | Owner: Adam Johnson Johnson | Type: | Status: assigned Cleanup/optimization | Component: Database | Version: dev layer (models, ORM) | Severity: Normal | Keywords: Triage Stage: | Has patch: 1 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- Another candidate for caching, like #35230 and #35232, following the same system check profiling.
`Model._meta.get_parent_list()` computes the flattened list of ancestor models by MRO. This list is immutable, deterministic, and recursively constructed through the inheritance hierarchy. These properties make it a prime candidate for caching. I found this method was taking ~1% of the total runtime for system checks on a project with 118 models. After adding caching, it’s reduced to a negligible amount. `get_parent_list()` is called in many other code paths, so caching will help all of those too. -- Ticket URL: <https://code.djangoproject.com/ticket/35241> 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/0107018dc8ad54ca-4e06889a-0acb-4a82-af95-6be4b8369464-000000%40eu-central-1.amazonses.com.