Using import_profiler, I've traced slow imports to networkx, especially:
networkx.generators (300ms)
networkx.linalg <- .algebraicconnectivity <- numpy (200ms)
networkx.readwrite <- .graphml <- xml.etree.cElementTree (100ms)
I'm not using linalg at all, and I rarely need readwrite. I don't think I need generators either. These three trees represent 60% of the import-time for networkx.
When my filesystem is slow, the import-times can be much worse.
I have a couple of ideas for you:
- If possible, avoid importing these unless they are needed.
- Or, depend on and use lazy-import for at least these 3 sub-trees.
Using import_profiler, I've traced slow imports to networkx, especially:
networkx.generators(300ms)networkx.linalg<-.algebraicconnectivity<-numpy(200ms)networkx.readwrite<-.graphml<-xml.etree.cElementTree(100ms)I'm not using
linalgat all, and I rarely needreadwrite. I don't think I needgeneratorseither. These three trees represent 60% of the import-time for networkx.When my filesystem is slow, the import-times can be much worse.
I have a couple of ideas for you: