I want to know what a pyc file(python bytecode) is. I want to know all the details. I want to know about how pyc files interface with the compiler. Is it a replacement for e
To supplement Mike Graham's answer there are some interesting comments here giving some information on pyc files. Most interestingly I suspect for you is the line:
A program doesn't run any faster when it is read from a ‘.pyc’ or ‘.pyo’ file than when it is read from a ‘.py’ file; the only thing that's faster about ‘.pyc’ or ‘.pyo’ files is the speed with which they are loaded.
Which hits the nail on the head w.r.t. the crux of a pyc file. A pyc
is a pre-interpreted py
file. The python bytecode is still the same as if it was generated from a py
file - the difference is that when using a pyc
file you don't have to go through the process of creating that pyc
output (which you do when running a py
file). Read as you don't have to convert the python script to python bytecode.
If you've come across .class files in java
this is a similar concept - the difference is in java you have to do the compiling using javac
before the java interpreter will execute the application. Different way of doing things (the internals will be very different as they're different languages) but same broad idea.