I'm pretty new to jython and I want to use jython to execute many existing python scripts.

For performance reason, I'm wondering if I can pre-compile the python scripts, like below:

private PyCode code = new PythonInterpreter().compile((new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(SCRIPT_NAME))));

And then reuse the compiled code in a multi-thread environment, like below:

public void someMethod() {
    PythonInterpreter interpreter = new PythonInterpreter();
    // ...

Looks like the doc doesn't mention if PyCode is thead-safe. Could anyone please give out some clarifications, or suggestions if this approach is incorrect.