the prior section talked about importing modules without really explaining what happens when you do so because imports are at the heart of program structure in pythonthis section goes into more formal detail on the import operation to make this process less abstract some programmers like to compare the python module import operation to #includebut they really shouldn' --in pythonimports are not just textual insertions of one file into another they are really runtime operations that perform three distinct steps the first time program imports given file find the module' file compile it to byte code (if needed run the module' code to build the objects it defines to better understand module importswe'll explore these steps in turn bear in mind that all three of these steps are carried out only the first time module is imported during program' executionlater imports of the same module in program run bypass all of these steps and simply fetch the already loaded module object in memory technicallypython does this by storing loaded modules in table named sys mod ules and checking there at the start of an import operation if the module is not presenta three-step process begins find it firstpython must locate the module file referenced by an import statement notice that the import statement in the prior section' example names the file without py extension and without its directory pathit just says import binstead of something like import :\dir \ py path and extension details are omitted on purposeinsteadpython uses standard module search path and known file types to locate the module file corresponding to an import statement because this is the main part of the import operation that programmers must know aboutwe'll return to this topic in moment it' syntactically illegal to include path and extension details in standard import howeverpackage importswhich we'll discuss in allow import statements to include part of the directory path leading to file as set of period-separated names package importsthoughstill rely on the normal module search path to locate the leftmost directory in package path ( they are relative to directory in the search paththey also cannot make use of any platform-specific directory syntax in the import statementssuch syntax only works on the search path alsonote that module file search path issues are not as relevant when you run frozen executables (discussed in )which typically embed byte code in the binary image modulesthe big picture