You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For several operations on polynomials (e.g. addition, substraction) the ABCPolyBase._get_coefficients takes time. The check np.all(self.domain == other.domain) can be replaced with either np.array_equal(self.domain, other.domain).all() or (self.domain == other.domain).all() (and similar for the window). For benchmark
from numpy.polynomial import Polynomial
import timeit
p = Polynomial([1,2,3])
q = Polynomial([3,2,1])
dt=timeit.timeit('p + p - q', globals={'p': p, 'q': q}, number=40_000)
print(dt)
The fastest option does assume the domain already is a numpy array. Current main and the np.array_equal option cast (with asarray). #24499
The numpy.polynomial.polyutils.as_series is called in many places. Also in internal methods where many of the input checks (e.g. on input dimensions) are not required. We can add a flag internal : bool to as_series than will skip several of the checks. Draft PR: MAINT: Improve performance of polynomial operations (2) #24531
Profiling results on main (2023-8-22) for p * q with p=Polynomial([1,2,3]); q=Polynomial([3,0,3]):
The text was updated successfully, but these errors were encountered:
Hello,
I would like to make a contribution to Numpy and I found this enhancement on the issue list.
I don't have that much free time, so it would likely take a while for me to work on this issue.
I have a couple questions:
Is this enhancement a high priority for Numpy development?
Do you know of other issues that are likely a higher priority than this one?
For context, I'm a first-time contributor to this project, so I'm not really sure what the important issues are.
Uh oh!
There was an error while loading. Please reload this page.
Proposed new feature or change:
The
numpy.polynomial
classes have quite some overhead in the calculations. This is a collection of ideas to reduce the overheadABCPolyBase._get_coefficients
takes time. The checknp.all(self.domain == other.domain)
can be replaced with eithernp.array_equal(self.domain, other.domain).all()
or(self.domain == other.domain).all()
(and similar for thewindow
). For benchmarkthe timings are
The fastest option does assume the
domain
already is a numpy array. Current main and thenp.array_equal
option cast (withasarray
). #24499numpy.polynomial.polyutils.as_series
is called in many places. Also in internal methods where many of the input checks (e.g. on input dimensions) are not required. We can add a flaginternal : bool
toas_series
than will skip several of the checks. Draft PR: MAINT: Improve performance of polynomial operations (2) #24531Profiling results on main (2023-8-22) for

p * q
withp=Polynomial([1,2,3]); q=Polynomial([3,0,3])
:The text was updated successfully, but these errors were encountered: