On Thu, Oct 11, 2012 at 10:58 PM, Łukasz Rekucki <lreku...@gmail.com> wrote: > On 11 October 2012 10:20, Russell Keith-Magee <russ...@keith-magee.com> wrote: >> >> And don't just say "Why are Django's URL resolvers slow?". Do some >> profiling, and come back with an analysis of where the time is being >> spent and/or wasted. > > FWIW, here's a link to a cProfile result for the mentioned > benchmark[1] on Django 1.4.1 and CPython 2.7.3. A quick look shows > that we're calling get_language() 1.5mln times (read: for every > pattern), so that's definitely going to slow down things. > > I'll try running the same with 1.3 and maybe 1.4 without the locale > mixin and post if I find anything interesting. > > [1]: https://gist.github.com/3875701 > >
It definitely doesn't help; ideally language code should be calculated once per call to resolve, and the same value used throughout. Hard-coding a value of 'en' for language code in LocaleRegexProvider.regex gives an idea of what gains would be: Stock django: static[0] msec rps tcalls funcs django 1583 6318 143 69 static[-1] msec rps tcalls funcs django 20879 479 1934 70 Hard coded 'en' in LocaleRegexProvider.regex: static[0] msec rps tcalls funcs django 1424 7023 133 67 static[-1] msec rps tcalls funcs django 4972 2011 929 68 static[0] represents tests matching the first URL in the urlconf, static[-1] represents tests matching the approximately 100th URL in the urlconf. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.