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 exe?
Does it need to be run by python?
Is it as portable as the .py file is?
Where should I use this?
I want to know what a pyc file(python bytecode) is. I want to know
Share
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:
Which hits the nail on the head w.r.t. the crux of a pyc file. A
pycis a pre-interpretedpyfile. The python bytecode is still the same as if it was generated from apyfile – the difference is that when using apycfile you don’t have to go through the process of creating thatpycoutput (which you do when running apyfile). Read as you don’t have to convert the python script to python bytecode.If you’ve come across .class files in
javathis is a similar concept – the difference is in java you have to do the compiling usingjavacbefore 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.