Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Help the specializing adpative interpreter #1522

Merged
merged 4 commits into from
Dec 31, 2022

Conversation

MartinThoma
Copy link
Member

@MartinThoma MartinThoma commented Dec 30, 2022

This PR aims at making minor changes that do not influence readability in a negative way and help (a tiny bit) to make pypdf faster.

https://pypi.org/project/specialist/ was used.

Specialized instructions

You can see the specialized instructions with the dis module:

python            
Python 3.11.0 (main, Oct 29 2022, 16:38:13) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dis
>>> your_function = lambda n: n * 1.5
>>> dis.dis(your_function, adaptive=True)
  1           0 RESUME                   0
              2 LOAD_FAST                0 (n)
              4 LOAD_CONST               1 (1.5)
              6 BINARY_OP                5 (*)
             10 RETURN_VALUE
>>> your_function(1.5)
2.25
>>> your_function(2.5)
3.75
>>> your_function(3.5)
5.25
>>> your_function(4.5)
6.75
>>> your_function(5.5)
8.25
>>> your_function(6.5)
9.75
>>> your_function(7.5)
11.25
>>> your_function(8.5)
12.75
>>> your_function(9.5)
14.25
>>> dis.dis(your_function, adaptive=True)
  1           0 RESUME_QUICK             0
              2 LOAD_FAST__LOAD_CONST     0 (n)
              4 LOAD_CONST               1 (1.5)
              6 BINARY_OP_MULTIPLY_FLOAT     5 (*)
             10 RETURN_VALUE
  • BINARY_OP_MULTIPLY_FLOAT: Multiplying two integers
  • BINARY_OP_MULTIPLY_INT: Multiplying two floats

See also

@MartinThoma MartinThoma added the nf-performance Non-functional change: Performance label Dec 30, 2022
@codecov
Copy link

codecov bot commented Dec 30, 2022

Codecov Report

Base: 91.83% // Head: 91.83% // No change to project coverage 👍

Coverage data is based on head (5fc0bb6) compared to base (82f9c1e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1522   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files          33       33           
  Lines        6073     6073           
  Branches     1193     1193           
=======================================
  Hits         5577     5577           
  Misses        321      321           
  Partials      175      175           
Impacted Files Coverage Δ
pypdf/_cmap.py 95.23% <100.00%> (ø)
pypdf/_codecs/__init__.py 100.00% <100.00%> (ø)
pypdf/_reader.py 90.36% <100.00%> (ø)
pypdf/_writer.py 83.75% <100.00%> (ø)
pypdf/generic/_annotations.py 96.66% <100.00%> (ø)
pypdf/xmp.py 92.10% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MartinThoma MartinThoma merged commit 6407e1d into main Dec 31, 2022
@MartinThoma MartinThoma deleted the specializing-adaptive-interpreter branch December 31, 2022 08:44
MartinThoma added a commit that referenced this pull request Dec 31, 2022
Performance Improvement (PI)
-  Help the specializing adpative interpreter (#1522)

New Features (ENH):
-  Add support for page labels (#1519)

Bug Fixes (BUG):
-  upgrade clone_document_root (#1520)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nf-performance Non-functional change: Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant