#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 Adam Johnson):

 If I understand correctly, the idea is that `_route_to_regex()` may return
 a “plain” string if no converters are found. Then in
 `RoutePattern.match()`, any such “plain” strings will be matched with
 `str.startswith` or `==`, depending on `_is_endpoint`, avoiding the
 overhead of performing a regex search?

 It seems like a legitimate optimization, but saving nanoseconds is maybe a
 little small for the added complexity. I suppose it would multiply across
 the number of routes.

 Can you make a draft PR with your patch? Does it pass all existing tests?
 We’d need to be extra careful here.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35518#comment:3>
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/010701900d7d0f80-1b0878a2-f0dd-4f28-997c-47148331b01d-000000%40eu-central-1.amazonses.com.

Reply via email to