pyfpdf
pyfpdf copied to clipboard
performance improvements
With this speedup, when you have various pages with png images, the improvements is significant. As a example, I used an old dual core machine, with 104 png images (16MB per image), to generate a pdf, 1 image per page. The time consuming before was 1 minute and 28 seconds. After this patch, the time is 6 seconds!!! Yes, 6 seconds, 14,7x faster!
The general idea sounds good to me. Writing into BytesIO or similar should be well optimized, and concatenating strings in Python performs badly in this sort of scenario.
@reingart: This patch is good to be merged?
Thank you for this performance work. Swapping in this version reduced the build time for a 112MB, 228 page PDF containing over 4500 images from 40 minutes to 30 seconds - an awesome improvement.
This offers a huge performance benefit, any chance this will get merged?
@alallier you may want to check out #171 and also check out this link to see that the fpdf2 fork uses a bytearray instead of a string (and is otherwise maintained):
https://github.com/PyFPDF/fpdf2/blob/master/fpdf/fpdf.py#L178
Thanks for the link. I noticed shortly after that this project was abandoned which is unfortunate