-
Notifications
You must be signed in to change notification settings - Fork 258
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
Reduce import-time loads of external modules #698
Comments
Sure - but - how much time would we be saving, do you think? |
I frequently get about a 1s import for nibabel. Which isn't too bad in itself, but as I'm trying to pare down import times for libraries with more dependencies, nibabel is one of several that add noticeably to the load time, and typically the hardest to isolate. I wrote a profiler to time successive imports and count the number of modules and virtual memory allocations after each successive import. Here it shows about a 450ms load time (after loading
|
I think it's a good idea to avoid import |
I think it shouldn't be too much trouble. I'll have a look maybe tomorrow. And I think it's probably fine to ignore PIL and xml, looking at those numbers. |
Beyond numpy, nibabel loads the following modules on import:
At minimum, I would say
nibabel.testing
does not need to be loaded when I runimport nibabel
, but I also thinkPIL
,h5py
,pydicom
andXML
probably don't need to be loaded unless you use a file format that requires them.Particularly given
nibabel's
position as a basic requirement for practically the entire Python neuroimaging ecosystem, we should try to be a lightweight import.The text was updated successfully, but these errors were encountered: