#35518: Avoid regex search for simple route patterns
-------------------------------------+-------------------------------------
     Reporter:  Jake Howard          |                    Owner:  Jake
         Type:                       |  Howard
  Cleanup/optimization               |                   Status:  closed
    Component:  Core (URLs)          |                  Version:  5.0
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Jake Howard):

 I've run some benchmarks against https://github.com/wagtail/bakerydemo,
 comparing `main` to my branch, intentionally choosing a path without a
 match to get a worst-case benchmark:

 **Before**:

 {{{#!python
 In [2]: %timeit -n 10000 resolve("/foo/")
 44.8 µs ± 18.5 µs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
 }}}


 **After**:

 {{{#!python
 In [3]: %timeit -n 10000 resolve("/foo/")
 39.7 µs ± 4.24 µs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
 }}}

 That's much less noticeable than I was expecting, and realistically within
 the margin of error. `bakerydemo` isn't the largest project, and I suspect
 that because the URL pattern tree is hierarchical, it'll only make a
 notable difference when a given node has a large number of children,
 rather than being useful in blanket. That's still likely to cover a non-
 zero number of projects.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35518#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190109a5dbc-167e3653-c930-4d96-ba6a-2ecc672c9274-000000%40eu-central-1.amazonses.com.

Reply via email to