Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making FPDF.output() x100 time faster by using a bytearray buffer #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Making FPDF.output() x100 time faster by using a bytearray buffer #164

wants to merge 2 commits into from

Conversation

Lucas-C
Copy link

@Lucas-C Lucas-C commented Aug 26, 2020

There is a detailed article explaining why this is faster:
https://www.guyrutenberg.com/2020/04/04/fast-bytes-concatenation-in-python/

On a document I'm working on with over 12 000 pages,
thanks to this patch the output generation passed from taking 20 minutes to 2 seconds.

@Lucas-C
Copy link
Author

Lucas-C commented Sep 5, 2020

I added a commit that also improves the performances of internal calls to ._out() (_e.g. inside FPDF.image()),
using the same approach.
This new commit also introduces DEBUG logs indicating the sizes of the final doc sections.

…approach + introducing DEBUG logs indicating the sizes of the final doc sections
@tkon99
Copy link

tkon99 commented Oct 27, 2020

Can confirm that this works wonders, master version did not finish within 20 minutes for 1040 pages of images, this did it in 5 seconds. Cheers! Hope it gets added soon.

@alexanderankin
Copy link

alexanderankin commented Oct 27, 2020 via email

@Lucas-C
Copy link
Author

Lucas-C commented Oct 27, 2020

I was planning to release a pyfpdf2 lib on Pypi before the end of the year, but I realize someone has already done that ! :D

@alexanderankin, do you think other commits from my fork could be merged into yours ?
cf. https://github.com/Lucas-C/pyfpdf#pyfpdf-fpdf-for-python

I'd be willing to contribute to a maintained fork of pyfpdf :)

@alexanderankin
Copy link

alexanderankin commented Oct 27, 2020 via email

@Lucas-C
Copy link
Author

Lucas-C commented Jan 6, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants