Skip to content

Render takes increasingly long on large number of variables #74

Done

Description

@cvas22

Copied from python-docx-template issue 490, opened by @gnadlr on 2023-04-27.


I have a template with around 12.000 variables (text only) and rendering takes a whooping 27 minutes. Is there any way to speed up rendering? Thank you.


Comments from the original thread

@elapouya on 2023-04-27:

Did you try PyPy interpreter ?

Activity

  1. added
    help wanted
    on Nov 9, 2026
  2. cvas22 commented on Nov 25, 2026

    @cvas22
    OwnerAuthor

    @gnadlr found a big part of it: replacing the document body at the end of render took quadratic time in lxml, so large templates got slower and slower. Fixed in #210, rendering is linear now and 12,000 variables take a couple of seconds in my tests. I could not get anywhere near 27 minutes with generated templates though, so if it is still slow for you, attach the template (with dummy data) and I will reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions