Chameleon 和 Jinja2 之间的速度比较
这里有人对 Chameleon 与 Jinja2 的性能进行过基准测试吗?我更习惯 Jinja 语法,因为我来自 Django,但正如 Pyramid 建议使用 Chameleon,我想尝试一下是否会很好 - 尽管语法很尴尬,IMO。
Has anyone here done any benchmarking of Chameleon versus Jinja2, in respect to performance? I'm more used to the Jinja syntax, since I come from Django, but as Pyramid suggests to use Chameleon, I'm thinking if it would be nice to give it a try - despite having an awkward syntax, IMO.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
模板引擎很少是性能问题的原因,即使 chameleon 比 Jinja2 稍快,我怀疑学习新模板语言等的努力是否值得。
数据库查询和缓存的优化可能会带来比切换模板引擎更高的性能,而且只需很少的努力。
Template engines are rarely the cause of performance problems, even if chameleon is slightly faster than Jinja2 I doubt the effort of learning a new template language etc. is worth it.
Optimization of database queries and caching will probably result in more performance than you could gain by switching the template engine and take little effort.
我认为他们非常接近,并且根据基准,每个人都可能获胜。我认为最好根据您对语法的喜欢程度(我更喜欢 pyTenjin)和简单程度来选择模板引擎就是将其集成到自己的项目/框架中。
Jinja2 的速度与 Mako 类似(比 Django 快约 20 倍): 来源
Chameleon 也比 Django 快约 20 倍: 来源
pyTenjin 也在上面:来源
I think they are pretty close, and each would probably win depending on the benchmark. I think it's better to pick a templating engine based on how much you like the syntax (I prefer pyTenjin) and how easy it is to integrate it into your own project/framework.
Jinja2 is similar to Mako in speed (~20x faster than Django): source
Chameleon is also about 20x faster than Django: source
And pyTenjin is also up there: source
请记住,jinja2 还通过 pyramid_jinja2 有一组“官方”金字塔
绑定比 Jinja2 更“核心”,主要是金字塔 repoze.bfg 历史的产物
Keep in mind that jinja2 also has an "official" set of pyramid bindings via pyramid_jinja2
The fact that Chamelon is anymore "core" than Jinja2 is mostly an artifact of pyramid's history of repoze.bfg