Issue
During interactive IPython notebook sessions, that usually only require normal imports, sometimes there is a need to import an occasional .pyo file.
Is there any IPython magic or a python API to do that?
Solution
Python imports .pyo files only if run with with -O
option:
python -O
Starting the whole IPyhon Notebook with this option does seem to work. At least I did not get to work.
As this issue points out, a workaround would be to rename the .pyo file into a .pyc file. Than Python will import it:
Actually it's a lot easier than that, although it is very much a hack: just rename the .pyo files to .pyc, and python without -O will happily import them. Since the optimization happens when the bytecode is written, this does what you want.
R. David Murray (r.david.murray)
Answered By - Mike Müller
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.