Avoid multiple import of the same packages in several python modules

Viewed 199

I'm designing a Python package with this structure :

package
 |_subpackage1
     |_module11.py
     |_module12.py
     |___init__.py
 |_subpackage2
     |_module21.py
     |_module22.py 
     |___init__.py
 |___init__.py

All modules require common external packages like numpy or os, and call each other: for instance module11 calls module21 and module11 calls module21

So far, all my module have a very long import header, to import the external packages and my own modules. I remarked that when I call my module with Ananconda, my scripts are very slow to initialize, and I presume it is because of those complex inter-connected imports

What should I put in the different __init__.py to avoid multiple imports of the same package, and long header in each module, both for the external packages and my own modules ?

0 Answers
Related