Skip to content

Slow operation with some PDFs #87

@rrthomas

Description

@rrthomas

(FIXME: update this issue from email correspondence about it.)

Seems like a lot of time is spent in _page.py's _merge_resources method, and of that, a lot is spent in typing's __instancecheck__.

pstops -pletter 16:0(0.50w,0.00h)+15(0.00w,0.00h)+3U(1.00w,1.00h)+12U(0.50w,1.00h),1(0.0w,0.00h)+14(0.50w,0.00h)+2U(0.5w,1.00h)+13U(1.00w,1.00h),4(0.50w,0.0h)+11(0.0w,0.0h)+7U(1.00w,1.00h)+8U(0.50w,1.00h),5(0.0w,0.0h)+10(0.50w,0.0h)+9U(1.00w,1.00h)+6U(0.50w,1.00h) 2026_weekbook_trial_002.pdf 2026_weekbook_trial_002_pstops.pdf
^C         21299954039 function calls (21299827432 primitive calls) in 3278.968 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    179/1    0.003    0.000 3278.969 3278.969 {built-in method builtins.exec}
        1    0.000    0.000 3278.969 3278.969 <string>:1(<module>)
        1    0.000    0.000 3278.969 3278.969 <frozen runpy>:201(run_module)
        1    0.000    0.000 3278.905 3278.905 <frozen runpy>:65(_run_code)
        1    0.000    0.000 3278.905 3278.905 pstops.py:1(<module>)
        1    0.000    0.000 3278.905 3278.905 pstops.py:104(pstops)
        1    0.000    0.000 3278.791 3278.791 transformers.py:65(transform_pages)
        1    0.000    0.000 3278.791 3278.791 transformers.py:85(transform_pages)
       29    0.001    0.000 3278.790  113.062 transformers.py:408(write_page)
      115    0.000    0.000 3278.782   28.511 _page.py:1362(merge_transformed_page)
      115    0.003    0.000 3278.782   28.511 _page.py:1069(_merge_page)
      115    0.021    0.000 3278.779   28.511 _page.py:1183(_merge_page_writer)
      343  348.757    1.017 3277.685    9.556 _page.py:832(_merge_resources)
1934603605  508.871    0.000 2872.005    0.000 _data_structures.py:457(__setitem__)
3871073973  511.737    0.000 2363.351    0.000 {built-in method builtins.isinstance}
3869298699 1010.219    0.000 1851.614    0.000 typing.py:1871(__instancecheck__)
3869298702  319.951    0.000  676.984    0.000 <frozen abc>:117(__instancecheck__)
3869298702  357.032    0.000  357.033    0.000 {built-in method _abc._abc_instancecheck}
3869305979/3869305066  164.413    0.000  164.415    0.000 {built-in method builtins.getattr}
   472591   51.103    0.000   51.104    0.000 {built-in method builtins.sorted}
   472572    2.520    0.000    2.520    0.000 {method 'clear' of 'dict' objects}
478776/472572    0.540    0.000    1.432    0.000 _base.py:337(clone)
   472572    0.733    0.000    1.318    0.000 _page.py:849(compute_unique_key)
172625/87450    0.150    0.000    0.916    0.000 _data_structures.py:1435(read_object)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions