Opened 5 years ago

Last modified 2 years ago

#14200 new Cleanup/optimization

new RegexURLResolver is contructed for every request

Reported by: Suor Owned by: Suor
Component: Core (URLs) Version: 1.2
Severity: Normal Keywords: performance, urlresolvers
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


urlresolvers provide memoized convenience function get_resolver() but django.core.handlers.base.BaseHandler does not use it.

Attachments (1)

memoize.urlresolver.diff (1.1 KB) - added by Suor 5 years ago.

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by Suor

comment:1 Changed 5 years ago by mk

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set

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:

The patch at least needs improvement and probably additional justification too.

comment:2 Changed 4 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by graham_king

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:4 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 3 years ago by claudep

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 Changed 2 years ago by aaugustin

  • Component changed from Core (Other) to Core (URLs)
Note: See TracTickets for help on using tickets.
Back to Top