编译Python代码
我没写错标题,我确实是想说如何编译Python代码。:-)
见下:
$ cat foo.py
print “hello”
$ ls
foo.py
$ python -mpy_compile foo.py
$ ls
foo.py foo.pyc
$ python foo.pyc
hello
或者另一种方式:
$ ls dummy/
foo.py
$ python -mcompileall dummy/
Listing dummy/ …
Compiling dummy/foo.py …
$ ls dummy/
foo.py foo.pyc
参考:
1. http://pyfaq.infogami.com/how-do-i-create-a-pyc-file
2. http://effbot.org/zone/python-compile.htm