Open eendebakpt opened 1 year ago
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.
I just saw that you already have a PR out for this issue that hasn't yet been merged in. I will therefore let you continue working on this.
Do you still wish to get this PR merged?
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
). https://github.com/numpy/numpy/pull/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: #24531Profiling results on main (2023-8-22) for
p * q
withp=Polynomial([1,2,3]); q=Polynomial([3,0,3])
: