Is it possible to import a compiled python file?

Jonno picture Jonno · Mar 28, 2012 · Viewed 30.9k times · Source

I can't seem to figure out how to import a compiled .pyc module into my code so I can use it within my main script. Is this even possible?

Answer

Intra picture Intra · Mar 28, 2012

If there is foo.pyc, import foo will automatically use foo.pyc whether foo.py exists or not

(If foo.py is newer, it will be used)

http://docs.python.org/tutorial/modules.html