gwsignal is very slow to import
I noticed in Bilby CI testing that our unit test that calls the gwsignal source model is very slow and tracked it down to importing lalsimulation.gwsignal
.
I think this is due to a direct import of pyseobnr
, even when one doesn't want to use an EOB waveform. Would it be possible to make this a lazy import in some way?
A 1 minute import time isn't really acceptable, especially if we want to eventually want to use the new interface for low-latency PE (I know that's a few iterations down the line.)
(igwn) [colm.talbot@ldas-pcdev1:~] [Thu Feb 22, 13:31:02]
$ ipython
import Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.21.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: %time from lalsimulation import gwsignal
/cvmfs/software.igwn.org/conda/envs/igwn-py310-20240206/lib/python3.10/site-packages/lalsimulation/lalsimulation.py:8: UserWarning: Wswiglal-redir-stdio:
SWIGLAL standard output/error redirection is enabled in IPython.
This may lead to performance penalties. To disable locally, use:
with lal.no_swig_redirect_standard_output_error():
...
To disable globally, use:
lal.swig_redirect_standard_output_error(True)
Note however that this will likely lead to error messages from
LAL functions being either misdirected or lost when called from
Jupyter notebooks.
To suppress this warning, use:
import warnings
warnings.filterwarnings("ignore", "Wswiglal-redir-stdio")
import lal
import lal
CPU times: user 41.5 s, sys: 1.38 s, total: 42.9 s
Wall time: 1min 27s
(I wasn't sure what template to use as it doesn't really seem like a bug.)