Saturday, 5 December 2015

Python: Compile all modules

By using the module 'compileall', you can compile all the python files in a directory. ‘python3.5 -m compileall .’ statement compile all the python files in current directory and place all the compiled files in the directory __pycache__.
$ ls
arithmetic.py main.py
$ 
$ python3.5 -m compileall .
Listing '.'...
Compiling './arithmetic.py'...
Compiling './main.py'...
$ 
$ ls
__pycache__ arithmetic.py main.py
$ 
$ ls -l __pycache__/
total 16
-rw-r--r--  1 harikrishna_gurram  myDomain Users  530 Oct 16 11:37 arithmetic.cpython-35.pyc
-rw-r--r--  1 harikrishna_gurram  myDomain Users  401 Oct 16 11:37 main.cpython-35.pyc


References




Previous                                                 Next                                                 Home

No comments:

Post a Comment