pythoncompiledinterpreted-languagepyc

If Python is interpreted, what are .pyc files?


Python is an interpreted language. But why does my source directory contain .pyc files, which are identified by Windows as "Compiled Python Files"?


Solution

  • They contain byte code, which is what the Python interpreter compiles the source to. This code is then executed by Python's virtual machine.

    Python's documentation explains the definition like this:

    Python is an interpreted language, as opposed to a compiled one, though the distinction can be blurry because of the presence of the bytecode compiler. This means that source files can be run directly without explicitly creating an executable which is then run.