Skip to content

PI: Decode PDFDocEncoding strings with a translation instead of per-character concatenation - #4429

Draft
MartinThoma wants to merge 5 commits into
mainfrom
pi-decode_pdfdocencoding
Draft

MartinThoma wants to merge 5 commits into
mainfrom
pi-decode_pdfdocencoding

Conversation

@MartinThoma

@MartinThoma MartinThoma commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

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

@MartinThoma MartinThoma changed the title PI: Decode PDFDocEncoding strings with a translation instead of per-character conccatenation PI: Decode PDFDocEncoding strings with a translation instead of per-character concatenation Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.87%. Comparing base (1e3e7e3) to head (11ecb15).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MartinThoma
MartinThoma force-pushed the pi-decode_pdfdocencoding branch from 1a1a996 to a150300 Compare November 14, 2026 10:10
@MartinThoma
MartinThoma force-pushed the pi-decode_pdfdocencoding branch from 0e52202 to 11ecb15 Compare November 14, 2026 13:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant