我有一个运行批处理作业的 java 应用程序。Java 应用程序通过 Jython 调用用 Python 编写的插件。在 java 应用程序启动期间,每个插件都会被初始化,如下所示:
// Prepare jython execution.
PythonInterpreter interp = new PythonInterpreter();
interp.set("currentpath", new PyString(pySig.getParent()));
FileInputStream fis = new FileInputStream(pySig);
try
{
interp.execfile(fis);
} finally
{
fis.close();
}
PyFunction pyFunc = (PyFunction) interp.get("id", PyFunction.class);
有没有办法提高 execfile 或 py 加载性能?我已经尝试以新的成功来持久化或序列化 PythonInterpreter 对象。任何速度改进都会很棒,因为每次都会为批处理作业加载插件。