Opened 14 years ago
Closed 9 years ago
#14200 closed Cleanup/optimization (fixed)
new RegexURLResolver is contructed for every request
Reported by: | Alexander Schepanovski | Owned by: | Marten Kenbeek |
---|---|---|---|
Component: | Core (URLs) | Version: | dev |
Severity: | Normal | Keywords: | performance, urlresolvers |
Cc: | marten.knbk@… | 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
urlresolvers provide memoized convenience function get_resolver() but django.core.handlers.base.BaseHandler does not use it.
Attachments (1)
Change History (12)
by , 14 years ago
Attachment: | memoize.urlresolver.diff added |
---|
comment:1 by , 14 years ago
Patch needs improvement: | set |
---|
comment:2 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:6 by , 12 years ago
With this patch, setting request.urlconf to None would return a resolver based on settings.ROOT_URLCONF instead of raising an ImproperlyConfigured exception. I have to say that I find this rather elegant and logic. Of course, this should be documented (and the failing test fixed). Opinions?
comment:7 by , 12 years ago
Component: | Core (Other) → Core (URLs) |
---|
comment:8 by , 9 years ago
Cc: | added |
---|---|
Has patch: | unset |
Owner: | changed from | to
Patch needs improvement: | unset |
Status: | new → assigned |
Version: | 1.2 → master |
I agree with Claude, falling back to settings.ROOT_URLCONF is quite elegant and logical. I'll write up a patch for this.
comment:10 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Did you do some performance testing? I'm not sure whether this really impacts performance in a noticeable negative way.
Anyway, applying this patch breaks the testsuite (FAIL: test_urlconf_overridden_with_null (regressiontests.urlpatterns_reverse.tests.RequestURLconfTests)) and breaks assigning request.urlconf:
http://docs.djangoproject.com/en/dev/topics/http/urls/#how-django-processes-a-request
The patch at least needs improvement and probably additional justification too.