Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control where $py.class files go?

Tags:

jython

pyc

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

like image 932
Joonas Pulakka Avatar asked Jan 11 '11 08:01

Joonas Pulakka


1 Answers

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)
like image 56
Joonas Pulakka Avatar answered Sep 28 '22 12:09

Joonas Pulakka