performance of internationalized html templates performance of internationalized html templates flask flask

performance of internationalized html templates


Have you measured the impact of such an "optimization" on the whole request-response cycle? I'd be very surprised if you would see any meaningful speedups, especially when using a template language that is already known to be pretty darn fast, like Jinja2.

As a general rule: never optimize before having measured the potential gains of the optimization. Intuition is oftentimes completely wrong in this area. This is especially true when an optimization introduces complication in code, development or deployment - always measure if it is worth the hassle.

You'd probably have more success looking into optimizing database queries or caching of expensive operations (a dict lookup, which gettext basically is, is not expensive at all).


You're doing it wrong. You should never I18Nize variables (your first type), only static text (your second type). You need to I18Nize the strings that could be used in error, not the variable itself.

And optimization should be done at the message catalog (gettext) level, not in your code.