I am using the Django version of the Google App Engine in Python.
Is there a significant performance difference between setting loops in a template and putting them in python page handlers?
For example, I am comparing something like this:
{% for i in items %} <div id="item_{{i.key}}"> {{i.text}} </div> {% endfor %}
Something like this inside my Python code:
def returnHtml(items): item_array = [] for i in items: item_array.append("<div id='item_%s'>%s</div>" % (i.id, i.text) return "".join(item_array)
... which is then directly inserted into the django template in the tag, for example:
{{ item_html }}
This is a trivial example, realistic, I have more complex loops inside loops, etc. I like to put logic in python code because it is much easier to maintain. But I'm worried about the impact on performance.
Any thoughts? Thanks.
source share