Closed dieissonmartins closed 1 month ago
I doubt it. At least not transparently. python-pptx
is not design for concurrency and lxml
would have to be concurrent too, which doesn't sound likely.
What I would do personally is profile the code and see what parts are taking the most time and then address those. It could be you could do some "preparation" concurrently, like gather things from databases and so on into memory and then write the PPTX in a single thread but using all those assembled resources.
Any way to create slides in parallel with concurrent.futures? My intention would be to create super large presentations in seconds
ex: ` import concurrent.futures from pptx import Presentation
def create_slide(number): slide = prs.slides.add_slide(prs.slide_layouts[0]) title = slide.shapes.title title.text = f'Slide {number}'
def main(): total_slides = 10 with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: futures = [executor.submit(create_slide, i) for i in range(1, total_slides + 1)] for future in concurrent.futures.as_completed(futures): future.result()
if name == "main": prs = Presentation() main()`