Do templates offer a speed advantage and, if so, how much #1588
-
|
Before I start let me say thank you to all involved in developing fpdf2, it's a very useful tool and I appreciate your work. Templates are clearly a good thing in terms of development effort but are there circumstances where they offer a significant speed advantage over a just using the standard API calls? I've looked through the documentation but I don't see any reference to speed improvements as a motivation for using templates. I'm producing 4000 pdf documents in one run and each of the 4000 share a good deal in common. If it was possible to produce those documents faster that would be very attractive. The processing to produce the documents was developed using a non-template approach before it became apparent how many documents would be produced and now any speed improvements would be welcomed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @shearichard, Templates in fpdf2 are really meant to simplify development effort, not to make rendering faster. If you look at Because of that, there’s no pre-processing or caching carried across documents. Each PDF is still generated one by one with the normal API calls. In fact, I would even expect a slight overhead when using templates, since there’s a conversion step involved in rendering the template. |
Beta Was this translation helpful? Give feedback.
Hi @shearichard,
Templates in fpdf2 are really meant to simplify development effort, not to make rendering faster. If you look at
fpdf/template.py, the template system just reads elements in different input formats and render them by calling the standard API methods.Because of that, there’s no pre-processing or caching carried across documents. Each PDF is still generated one by one with the normal API calls. In fact, I would even expect a slight overhead when using templates, since there’s a conversion step involved in rendering the template.