Commit 795e25a
perf: lazy import pdfminer in pdf.py
Defer importing the pdf module (and pdfminer) until a PDF file is
actually matched. This is done via a lazy parser wrapper that registers
immediately but only imports the actual pdf module on first use.
The pdfminer library imports many submodules (cryptography, etc.) which
adds ~0.5s to import time. Most files aren't PDFs, so deferring this
import improves startup time for the common case.
Performance improvement:
- pdfminer no longer loaded at import time
- Import time reduced by ~28% (measured 527ms → 380ms in cached runs)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent abaef67 commit 795e25a
2 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
1166 | | - | |
| 1166 | + | |
1167 | 1167 | | |
1168 | 1168 | | |
1169 | 1169 | | |
| |||
0 commit comments