Opened 3 hours ago

Closed 27 minutes ago

#36242 closed Cleanup/optimization (wontfix)

NodeList render overhead with huge templates

Reported by: Michal Čihař Owned by:
Component: Uncategorized Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While debugging rendering of some huge templates, I've noticed that the rendering is slower and needs more memory than necessary because of:

    def render(self, context):
        return SafeString("".join([node.render_annotated(context) for node in self]))

which unnecessarily builds a list and then passes it to join, which could directly consume an iterable.

I will prepare a pull request with a fix.

Change History (1)

comment:1 by Mariusz Felisiak, 27 minutes ago

Resolution: wontfix
Status: newclosed

There is nothing to fix here. A list comprehension is preferable here as str.join() converts to list internally anyway. It is better performance to provide a list up front.

Note: See TracTickets for help on using tickets.
Back to Top