What is the fastest template system for Python?

前端 未结 5 1044
余生分开走
余生分开走 2020-12-07 08:43

Jinja2 and Mako are both apparently pretty fast.

How do these compare to (the less featured but probably good enough for what I\'m doing) string.Template ?

5条回答
  •  情歌与酒
    2020-12-07 09:15

    In general you will have to do profiling to answer that question, as it depends on how you use the templates and what for.

    string.Template is the fastest, but so primitive it can hardly be called a template in the same breath as the other templating systems, as it only does string replacements, and has no conditions or loops, making it pretty useless in practice.

提交回复
热议问题