Opened 8 years ago
Closed 8 years ago
#27625 closed Cleanup/optimization (fixed)
Make Settings avoid repeat getattr calls
Reported by: | Adam Johnson | Owned by: | Adam Johnson |
---|---|---|---|
Component: | Core (Other) | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | me@…, carl@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In 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
.
Change History (2)
comment:1 by , 8 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
PR