Opened 3 years ago
Closed 3 years ago
#32990 closed Cleanup/optimization (fixed)
Test the tag_re regex in template/base.py instead of evaluating it every time
Reported by: | Chris Jerdonek | Owned by: | gtwohig |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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.
Change History (6)
comment:1 by , 3 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 3 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 3 years ago
Has patch: | set |
---|
comment:4 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Submitted PR