#32990: Test the tag_re regex in template/base.py instead of evaluating it every
time
------------------------------------------------+------------------------
               Reporter:  Chris Jerdonek        |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Template system       |        Version:  dev
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  1
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 I noticed that `template/base.py` has a somewhat complicated regex string
 at the top involving six calls to `re.escape()` that it needs to evaluate
 every time:
 
https://github.com/django/django/blob/4fe3774c729f3fd5105b3001fe69a70bdca95ac3/django/template/base.py#L90-L93

 A more efficient approach would be to define a hard-coded `_TAG_RE_REGEX`
 regex at the top that is the result of that substitution, and add a test
 checking that it matches the result of calling `re.escape()` six times,
 etc. That would eliminate the need to do the substitution at runtime.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32990>
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/052.8e6e9f54d5e97a0ff484402fee046a35%40djangoproject.com.

Reply via email to