Skip to content

Commit

Permalink
pdf_renderer: prefer one-liners
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Mar 18, 2022
1 parent 4aa6427 commit 7679052
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions src/pypdfium2/_helpers/pdf_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@
from pypdfium2._helpers.constants import OptimiseMode


def _process_page(
render_meth,
input_obj,
index,
password,
scale,
rotation,
colour,
annotations,
greyscale,
optimise_mode,
):
def _process_page(render_meth, input_obj, index, password, scale, rotation, colour, annotations, greyscale, optimise_mode):

with PdfContext(input_obj, password) as pdf:
result = render_meth(
Expand Down Expand Up @@ -75,24 +64,10 @@ def render_pdf_base(
elif any(i >= n_pages for i in page_indices):
raise ValueError("Out of range page index detected.")

meta_args = []
for i in page_indices:
sub_args = (
render_meth,
input_obj,
i,
password,
scale,
rotation,
colour,
annotations,
greyscale,
optimise_mode,
)
meta_args.append(sub_args)
args = [(render_meth, input_obj, i, password, scale, rotation, colour, annotations, greyscale, optimise_mode) for i in page_indices]

with concurrent.futures.ProcessPoolExecutor(n_processes) as pool:
for index, image in pool.map(_invoke_process_page, meta_args):
for index, image in pool.map(_invoke_process_page, args):
suffix = str(index+1).zfill(n_digits)
yield image, suffix

Expand Down

0 comments on commit 7679052

Please sign in to comment.