Import Tips

Learn how to import anything more efficiently in Python.

We'll cover the following...

Import wisely

Modules are the building blocks of the Python ecosystem. A typical Python program imports dozens of modules, but we should always try to minimize how many modules we import.

If nothing in a file depends on some module, that module shouldn’t be imported. Importing a module takes time that we could better use for something else. Also, any import statement introduces a dependency. If the module goes unused, it’s a false dependency. If the unnecessary module is removed from the system, such ...