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 14290 Rendering is very inefficient when USE_L10N. Caching format values gives 2-7 times improvement Teemu Kurppa Jannis Leidel "Django's rendering is really inefficient if localization is turned on (USE_L10N = True). I have a spreadsheet like view with a few thousand numbers, dates and related data and it spend almost all of it's time in template rendering even when I preprocessed data carefully. I investigated the issue and it seems that Django's localization implementation is doing a lot of unnecessary work for every rendered number, date and time. Following patch introduces caching of locale-specific format values. Speed improvements are considerable. On my laptop and our server, this gives '''5-7 times improvement''' (from ~5 sec to <1sec) to rendering speed of an anomalistic view with 10000 integers. For my real-world spreadsheet view, the whole processing time of Django improves 2-3 times (from ~2sec to ~0.8sec) In addition to the patch, I've included a test project, which can be used to test observe and test the problem. Run test to see raw rendering performance {{{ python manage.py test numbersperf }}} And to test it with server try {{{ python manage.py runserver }}} And then visit these urls to observe and profile the problem {{{ http://localhost:8000/test/10000 http://localhost:8000/test/10000?timing http://localhost:8000/test/10000?prof }}} " closed Internationalization dev fixed localization, rendering, Accepted 1 1 1 0 0 0