#27625: Make Settings avoid repeat getattr calls -------------------------------------+------------------------------------- Reporter: Adam | Owner: Adam Chainz Chainz | Type: | Status: assigned Cleanup/optimization | Component: Core | Version: 1.10 (Other) | 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 | -------------------------------------+------------------------------------- In [https://speakerdeck.com/carljm/instagram-under-the-hood Carl Meyer's talk at DUTH] on Instagram he noted a small 'hack' that add been added to their codebase to speed up all their requests: caching the first result of settings accesses in the outer `LazySettings` object's `__dict__` with a post-setup hook like:
{{{ for key in dir(settings): settings.__dict__[key] = getattr(settings, key) }}} `LazySettings` itself could do this caching in its own `__dict__` to give great speed to all! It can also be done in a way that is tested to interact better with other parts of Django, such as `override_settings`. -- Ticket URL: <https://code.djangoproject.com/ticket/27625> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/053.cc6305875618982ac9b6c4e4a7f13f94%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.