Bill H. answered 05/17/18
Tutor
4.9
(1,367)
Over 20 years of Python programming and 4000 hours of tutoring.
.py files are the original text files holing python code.
.pyc files are compiled versions of the .py files.
Whenever your code imports a module the interpreter imports the .pyc version of it if it's available and it has a later modification date than the .py file. If a .pyc file does not exist the interpreter compiles the .py file and saves it as .pyc.
A .pyc is not created for your main program file that you execute (only for imported modules).
The .pyc file contains encoded python bytecode.