We can write a piece of python code and put it in already compiled ".pyc" file and use it. I am wondering that is there any kind of gain in terms of performance or it is just a kind of modular way of grouping the code.
Thanks a lot
There is no performance gain over the course of your program. It only improves the startup time.
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.
http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html
And pyo files being the next optimization just remove doc strings from your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With