From 0aeffb161bd2aa4aa3aec29f4cf6f3b22b714e06 Mon Sep 17 00:00:00 2001 From: Wolfgang Kastaun <wolfgang.kastaun@aei.mpg.de> Date: Tue, 11 Feb 2025 09:42:27 +0100 Subject: [PATCH] Performance optimization of interpolator to prevent annoying slowdown of small test problems Repeating small tests many times was order of magnitude slower. The reason is the computation of Lagrange polynomials was both inefficient and performed every time an RegularInterpLagrange instance was created. This causes overhead which is not relevant for large problem sizes but makes running many small tests slow. The fix for now is to cache the creation of the polynomials. Now they are created only onnce for each interpolation order, but not once per instance. --- lisainstrument/regular_interpolators.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lisainstrument/regular_interpolators.py b/lisainstrument/regular_interpolators.py index 6a99c1c..fb7a248 100644 --- a/lisainstrument/regular_interpolators.py +++ b/lisainstrument/regular_interpolators.py @@ -155,6 +155,7 @@ class RegularInterpLagrange(RegularInterpCore): """ @staticmethod + @functools.cache def _make_firs(length: int, offset: int) -> list[FilterFirNumpyType]: """Set up lagrange polynomials and convert coefficients to FIR filters""" plag = make_lagrange_polynomials(length, offset) -- GitLab