All code run by cpython must be compiled to bytecode before it can be run. That's just how the interpreter works, and you probably can't reasonably change this (without writing your own interpreter).
However, by default the compiled bytecode for modules that are loaded will be cached in .pyc
files. This means it won't need to be compiled again the next time you load it. Bytecode caching is probably what you heard about, as it can speed up the importing of previously used modules by a fair amount. It doesn't change performance after the modules are loaded though.
You can disable bytecode caching with the -B
command line option or the PYTHONDONTWRITEBYTECODE
environment variable. If you wanted to do a test of the speed difference, you may also need to delete any existing cache. In Python 2, the compiled bytecode would be written to a .pyc
file right next to the .py
souce file. In Python 3, this was changed to use a __pycache__
folder which can hold several .pyc
files from different versions of Python (so you could have several cached versions at once, see PEP 3147 for more details).