odoo/odoo#250888

Created by fw-bot
Merged at 43abaa0518315a7ed8a528c289da60d89eb86ab4

Statuses:

label
odoo-dev:18.0-17.0-memoise-locales-xmo-500673-fw
head
586f6ebcd76b6e6e383d66deec0a4c0be0d08fb9
merged
2 months ago by Framework (ORM), Xavier Morel (xmo)
odoo/odoo
17.0 #249795
18.0 #250888
saas-18.2 #251006
saas-18.3 #251028
saas-18.4 #251043
19.0 #251054
saas-19.1 #251124
saas-19.2 #251148
saas-19.3
master #251188

[IMP] core: add lru on `babel_locale_parse`

babel.Locale.parse checks if a locale is valid by calling os.path.exists on the resolved filename for the locale (this is done in babel.localedata.exists).

Babel does have a locale cache which it checks, but currently that cache is only populated when the locale is actually loaded1, therefore in cases where we instantiate a significant number of locales but never actually need to load locale data (e.g. formatting a significant number of datetimes, in qweb, using only non-localised patterns) this results in severe FS traffic for no reason.

Forward-Port-Of: #249795


  1. python-babel/babel#1254 has been submitted to fix this issue ↩