How to control where $py.class files go?
When importing modules for the first time, Jython creates $py.class
files (Jython equivalent of .pyc
) in the same directory as the corresponding .py
file.
A problem arises when the process has no permissions to write into that directory (everything works, but no $py.class
files, so undue compilation in the next time). In general, I feel uneasy that a process is automatically suppos开发者_开发技巧ed have write permission to the directory from where it reads code to be run.
Are there any tricks to make Jython write the compiled files into some dedicated cache directory? This question has previously been asked at Jython mailing list, but no replies so far...
Apparently there's no way to change the destination directory. But, there is a way to create all those classes beforehand, so in case of permission problems an administrator could create all $py.class
files at once, so that less-privileged users can take advantage of the bytecode caching. See:
- https://www.jython.org/jython-old-sites/docs/library/py_compile.html (was: http://www.jython.org/docs/library/py_compile.html)
- https://www.jython.org/jython-old-sites/docs/library/compileall.html (was: http://www.jython.org/docs/library/compileall.html)
精彩评论