py --> pyc ?

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.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, 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 do the job ?

python "yourDirectoryHere"

compiles all .py under yourDirectoryHere dir, recursively.
Simply adding a context menu for directory type works very well for me.