Content-Length: 312247 | pFad | https://github.com/numpy/numpy/pull/24499

CF MAINT: Optimize performance of polynomial operations by eendebakpt · Pull Request #24499 · numpy/numpy · GitHub
Skip to content

MAINT: Optimize performance of polynomial operations #24499

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

eendebakpt
Copy link
Contributor

Improve the performance of polynomial operations by improving the internal _get_coefficients:

  • Reorder type check for the most common operation
  • Use all() method of numpy arrays instead of np.all for the window and domain attributes

Benchmark results

p + q: Mean +- std dev: [main] 35.7 us +- 1.3 us -> [pr] 31.8 us +- 0.6 us: 1.12x faster
p * q: Mean +- std dev: [main] 37.3 us +- 1.1 us -> [pr] 33.9 us +- 1.1 us: 1.10x faster

Geometric mean: 1.11x faster

with script

import pyperf
from numpy.polynomial import Polynomial

setup = """
from numpy.polynomial import Polynomial

p=Polynomial([.5,4,5])
q=Polynomial([1,0,5])
"""

runner = pyperf.Runner()
runner.timeit(name=f"p + q", stmt="_ = p + q", setup=setup)
runner.timeit(name=f"p * q", stmt="_ = p * q", setup=setup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/numpy/numpy/pull/24499

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy