Repository navigation
PI: Decode PDFDocEncoding strings with a translation instead of per-character concatenation - #4429
Draft
MartinThoma wants to merge 5 commits into
Draft
MartinThoma wants to merge 5 commits into
MartinThoma wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4429 +/- ##
=======================================
Coverage 98.87% 98.87%
=======================================
Files 59 59
Lines 12299 12299
Branches 2342 2341 -1
=======================================
Hits 12161 12161
Misses 68 68
Partials 70 70 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…of per-character conccatenation
MartinThoma
force-pushed
the
pi-decode_pdfdocencoding
branch
from
November 14, 2026 10:10
1a1a996 to
a150300
Compare
MartinThoma
force-pushed
the
pi-decode_pdfdocencoding
branch
from
November 14, 2026 13:40
0e52202 to
11ecb15
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.
I just stumbled over this on pdfly: py-pdf/pdfly#295
I still need to test/benchmark this change.
General Problem Analysis
The for-loop with
retval += ceffectively needs to re-create and copy the string again and again in the worst case.pdfly problem analysis: Why only on Windows?
According to Mistral AI, this is an Issue only on Windows with Python 3.11, because glibc (realloc -> mremap) is effectively linear but Windows UCRT (realloc always copies) is quadratic. Anything tracing each executed line amplifies it further, e.g. covrage.py on Python < 3.12 turned a 0.3s clone into 66s in CI
Benchmarks to be done
Proof of functional eqivalence
TODO