jythonpyc

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 supposed 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...


Solution

  • 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: