Hi all,
How to get pyc from py?
Thanks in advance
Hi all,
How to get pyc from py?
Thanks in advance
pyc is python cache file they are made automatically when you run your program. There is a way to generate them without running your program.
python file.py = file.pyc + run the file.pyc
There are multiple ways to get pyc from py.
The easiest way is just to import the file. For example, if your file name is myfile.py, do:
import myfile
this will create a pyc file at that location.
Though, if you really want good compilation, I would use .pyo files, these are optimized pyc files. To have them run python with the -OO parameter instead.
Thank you for reply.
That means pyc or pyo should be run faster than py?
Yup. But if none are present, python will generate them automatically.
I don’t think pyc will run faster - I think it will load faster, though.
doesn’t compileall.py do the job ?
python compileall.py "yourDirectoryHere"
compiles all .py under yourDirectoryHere dir, recursively.
Simply adding a context menu for directory type works very well for me.