Repository navigation
Conversation
KRRT7
force-pushed
the
perf/skip-word-walk-without-annotations
branch
from
November 21, 2026 08:53
9a053a1 to
977fce3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a page has any link annotations,
process_page_layout_from_pdfminer()and_pdfminer_page_elements()calledget_words_from_obj()for everyLTTextBoxon the page, then used its result only for the annotations that overlap that box.get_words_from_obj()walks every character of the box. It now runs only whencheck_annotations_within_element()returned at least one annotation.get_words_from_obj()has no side effects, so output is unchanged.Performance
Walltime,
pytest-codspeedrun locally (Apple Silicon),process_page_layout_from_pdfminerover all 16 pages ofexample-docs/pdf/layout-parser-paper.pdf(109 link annotations), repeated runs:cProfile had
get_words_from_objat ~41% of this function before the change.Validation
test_unstructured/partition/pdf_image/test_pdfminer_processing.py,test_pdf.pyandtest_merge_elements.pypass.