search path after initializationpython programs can modify sys path the directory containing the script being run is placed at the beginning of the search pathahead of the standard library path this means that scripts in that directory will be loaded instead of modules of the same name in the library directory this is an error unless the replacement is intended see section standard modules for more information "compiledpython files to speed up loading modulespython caches the compiled version of each module in the __pycache__ directory under the name module version pycwhere the version encodes the format of the compiled fileit generally contains the python version number for examplein cpython release the compiled version of spam py would be cached as __pycache__/spam cpython- pyc this naming convention allows compiled modules from different releases and different versions of python to coexist python checks the modification date of the source against the compiled version to see if it' out of date and needs to be recompiled this is completely automatic process alsothe compiled modules are platform-independentso the same library can be shared among systems with different architectures python does not check the cache in two circumstances firstit always recompiles and does not store the result for the module that' loaded directly from the command line secondit does not check the cache if there is no source module to support non-source (compiled onlydistributionthe compiled module must be in the source directoryand there must not be source module some tips for expertsyou can use the - or -oo switches on the python command to reduce the size of compiled module the - switch removes assert statementsthe -oo switch removes both assert statements and __doc__ strings since some programs may rely on having these availableyou should only use this option if you know what you're doing "optimizedmodules have an opttag and are usually smaller future releases may change the effects of optimization program doesn' run any faster when it is read from pyc file than when it is read from py filethe only thing that' faster about pyc files is the speed with which they are loaded the module compileall can create pyc files for all modules in directory there is more detail on this processincluding flow chart of the decisionsin pep standard modules python comes with library of standard modulesdescribed in separate documentthe python library reference ("library referencehereaftersome modules are built into the interpreterthese provide access to operations that are not part of the core of the language but are nevertheless built ineither for efficiency or to provide access to operating system primitives such as system calls the set of such modules is configuration option which also depends on the underlying platform for examplethe winreg module is only provided on windows systems one particular module deserves some attentionsyswhich is built into every python interpreter the variables sys ps and sys ps define the strings used as primary and secondary promptsimport sys sys ps sys ps (continues on next page modules