﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36729	Pre-compile regular expressions as standard	Jake Howard	Jake Howard	"See also [https://forum.djangoproject.com/t/rfc-pre-compiling-regular-expressions-as-standard/43311 forum thread].

It's fairly well known that there's a performance boost pre-compiling regexes (either using `re.compile` or `_lazy_re_compile`, depending on popularity). However, some of Django's internals compile at time of use, which adds unnecessary extra work. Python's `re` module caches the most recent 512 patterns, however a reasonably sized Django project can easily go beyond that.

I suggest replacing patterns defined at runtime with pre-compiled patterns done at module import time (or `_lazy_re_compile` if the pattern isn't used much). This probably wants to be done as a single patch, rather than trying to separate per module or the ticket dragging on.

I also suggest reasonably rejecting any non pre-compiled regexes in the [https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#python-style coding style]."	Cleanup/optimization	assigned	Utilities	dev	Normal				Accepted	1	0	0	1	0	0
