Speeding up Python Imports
Question: I have a large program that is structured using object oriented techniques,
and I have one main driver module that imports a bunch of other classes, which
they in turn import more python built-in modules or other classes. All
together I would say there is well over 250 `from x import y statements` (I
don't have control over this part of the code), some are duplicates in other
classes and some are unique. I profiled my code and as I suspected the
majority of the time is in the start up with import so many modules and
classes. There is a way to speed up this?


Answer: [You can move the import statements to inside your functions to reduce initial
startup.](http://wiki.python.org/moin/PythonSpeed/PerformanceTips#Import_Statement_Overhead)

Another technique would be to copy your modules to a ramdisk or tmpfs for
faster IO (these use RAM, which runs much faster).

