﻿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
25743	Optimize formats.localize(_input)	Jaap Roes	nobody	"While doing some benchmarking on some simple templates I noticed `render_value_in_context` was spending a disproportionate amount of time in `utils.formats.localize` while rendering a simple string.

Performance increased greatly on my machine after simply altering `localize` to bail early on strings. (I did the same thing for `localize_input` where I saw the same pattern.)

Here's a benchmark script and my results before and after:

{{{
import timeit

print('localize(string): %s' % timeit.repeat('localize(""a"")', setup='from django.utils.formats import localize'))
print('localize_input(string): %s' % timeit.repeat('localize_input(""a"")', setup='from django.utils.formats import localize_input'))
}}}

Before:

{{{
localize(string): [1.886936140996113, 1.960805894996156, 1.9073195710006985]
localize_input(string): [1.6485704379956587, 1.6588637870008824, 1.6481186080054613]
}}}

After:

{{{
localize(string): [0.2906172150032944, 0.2897624880060903, 0.28507295199960936]
localize_input(string): [0.28498719700291986, 0.2985827610027627, 0.2751107259973651]
}}}"	Cleanup/optimization	closed	Utilities	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
