[Django] #27625: Make Settings avoid repeat getattr calls

4 views
Skip to first unread message

Django

unread,
Dec 22, 2016, 5:52:36 PM12/22/16
to django-...@googlegroups.com
#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.

Django

unread,
Dec 22, 2016, 7:23:09 PM12/22/16
to django-...@googlegroups.com
#27625: Make Settings avoid repeat getattr calls
-------------------------------------+-------------------------------------
Reporter: Adam Chainz | Owner: Adam
Type: | Chainz
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1
* stage: Unreviewed => Ready for checkin


Comment:

[https://github.com/django/django/pull/7732 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27625#comment:1>

Django

unread,
Dec 23, 2016, 10:58:26 AM12/23/16
to django-...@googlegroups.com
#27625: Make Settings avoid repeat getattr calls
-------------------------------------+-------------------------------------
Reporter: Adam Chainz | Owner: Adam
Type: | Chainz
Cleanup/optimization | Status: closed

Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c1b221a9b913315998a1bcec2f29a9361a74d1ac" c1b221a9]:
{{{
#!CommitTicketReference repository=""
revision="c1b221a9b913315998a1bcec2f29a9361a74d1ac"
Fixed #27625 -- Made LazySettings cache attributes in __dict__.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27625#comment:2>

Reply all
Reply to author
Forward
0 new messages