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
This is just to get a discussion starting (@clbarnes):
Currently most functions in navis are automatically imported at top-level.
Pros:
convenient because most functions are easy to call via navis.{function}
Cons:
importing navis is slow
for a many analyses one doesn't even need all functions
crowded namespace
any missing dependency breaks the whole package
My preferred way of improving the situation would be to break navis into functionalities and only the core functions are imported at top-level. It might be worth doing some profiling to see where the actual bottlenecks are.
What I would consider core functionality:
All neuron data models (i.e. navis.core)
The above requires navis.graph
navis.converters to move between neuron representations
In practice there aren't all that many modules that could be easily decoupled without re-organizing:
navis.nbl(NBLAST) is independent
navis.morpho and navis.plotting could be decoupled using lazy imports in the core modules
navis.tranforms and navis.data are also independent but probably won't save much time on import
navis.intersection could be decoupled
Other alternatives:
make imports conditional on some environment flag. For example backend user could set NAVIS_CORE=TRUE and navis only imports core functions at top level while for all other users the experience doesn't change
make expensive imports (like Matplotlib, VisPy, etc) lazy
I had a quick crack at the imports using python -X importtime and pasting the results of import navis into this website for visualisation:
The top 100 worst imports (if I understand the output correctly) are these:
This is just to get a discussion starting (@clbarnes):
Currently most functions in navis are automatically imported at top-level.
Pros:
navis.{function}
Cons:
My preferred way of improving the situation would be to break
navis
into functionalities and only the core functions are imported at top-level. It might be worth doing some profiling to see where the actual bottlenecks are.What I would consider core functionality:
navis.core
)navis.graph
navis.converters
to move between neuron representationsIn practice there aren't all that many modules that could be easily decoupled without re-organizing:
navis.nbl
(NBLAST) is independentnavis.morpho
andnavis.plotting
could be decoupled using lazy imports in the core modulesnavis.tranforms
andnavis.data
are also independent but probably won't save much time on importnavis.intersection
could be decoupledOther alternatives:
NAVIS_CORE=TRUE
and navis only imports core functions at top level while for all other users the experience doesn't changeI had a quick crack at the imports using
python -X importtime
and pasting the results ofimport navis
into this website for visualisation:The top 100 worst imports (if I understand the output correctly) are these:
Most of these
navis
doesn't directly import but for examplepint
is unfortunately very expensive.The text was updated successfully, but these errors were encountered: