#24221 closed Cleanup/optimization (fixed)
Use compiled regular expression when checking success_url
Reported by: | Tomáš Ehrlich | Owned by: | Tomáš Ehrlich |
---|---|---|---|
Component: | Generic views | Version: | 1.8alpha1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
While working on #24220 I also noticed that old-style formatting is checked using re.search
with inline regexp. Wouldn't it be better to compile regexp pattern in advance at top level? I don't know the real performance gain, but using precompiled regexp where possible is common sense to me.
if re.search(r'%\([^\)]+\)', self.success_url):
replace with:
percent_placeholder = re.compile(r'%\([^\)]+\)') ... def get_success_url(): if percent_placeholder.search(self.success_url):
Change History (3)
comment:1 by , 10 years ago
Has patch: | set |
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Added PR https://github.com/django/django/pull/3990