0

I am facing the task of optimizing the gluing of documents into 1 pdf/zip.

At the moment I only have single-threaded implementations, which work insanely long on a large number of files.

Writing to the archive:

for folder, file_list in folders.items():
        for file_obj, new_name in file_list:
            zip_file.writestr(
                validate_folder(str(folder)) + validate_name(file_obj.name, new_name),
                file_obj.open().read(),
            )

Writing to pdf:


        merger = PdfFileMerger()
        For file in files:
            merger.append(copy(file), import_bookmarks=False)

        c = ContentFile(b'')
        merger.write(c)

I have a suggestion to try doing all this in threads, but maybe a more reliable and faster option?

  • "You could execute WinRAR from Python" https://stackoverflow.com/questions/70881893/python-faster-library-to-compress-data-than-zipfile#:~:text=You%20could%20execute%20WinRAR%20from%20Python – Сергей Кох Nov 05 '22 at 18:33

0 Answers0