PI: optimize _decode_png_prediction#2068
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2068 +/- ##
==========================================
+ Coverage 94.23% 94.24% +0.01%
==========================================
Files 41 41
Lines 7340 7355 +15
Branches 1445 1448 +3
==========================================
+ Hits 6917 6932 +15
Misses 263 263
Partials 160 160
☔ View full report in Codecov by Sentry. |
|
unless I'm wrong, this filter is only for images: wouldn't it be more efficient to use pillow ? your opinion? |
|
i can not find any thing like this in |
|
Very nice work 👍 On my machine it's: The |
|
I'm updating the test code a bit ( #2072 ), but this improvement will almost certainly go into the release this weekend :-) |
|
I would like to add a new benchmark for this as well (before I merge, so that we can see the difference). The current benchmarks are not really helpful. Lets see if such a big change is visible. |
I had a quick review and found no solution.😳 |
|
https://py-pdf.github.io/pypdf/dev/bench/ -> look at the very bottom :-) This shows iterations per second, hence higher is better. Still, I'm a bit disappointed that the magnitude there is way lower than what @exiledkingcc and me observed. |
|
there is a huge mount of math calculations in the method, which is Python's weeknees. besides, it costs a lot of time for pillow to save png file. |
## What's new ### Performance Improvements (PI) - optimize _decode_png_prediction (#2068) ### Bug Fixes (BUG) - Fix incorrect tm_matrix in call to visitor_text (#2060) - Writing German characters into form fields (#2047) - Prevent stall when accessing image in corrupted pdf (#2081) - append() fails when articles do not have /T (#2080) ### Robustness (ROB) - Cope with xref not followed by separator (#2083) [Full Changelog](3.15.0...3.15.1)

this commit makes
tests/test_page.py::test_image_new_propertycost from 8.98s to 5.69s on my machine, about x1.5 faster.