I have several python scripts (eg a.py,b.py) that share the same overhead at the top, eg:
import matplotlib.pylab as plt
#and some Oracle database connection and reading.
Then I have a java script that users Runtime to calls these several python scripts separately:
Process p = Runtime.getRuntime().exec("python a.py");
p.waitFor();
...
p = Runtime.getRuntime().exec("python b.py");
p.waitFor();
I suffer from the repeated overhead due to the java Runtime and python import overhead during each python call. I am wondering whether there is a way that involves only one time overhead during the first python call (by passing around some python handler/state maybe?) I am open to third party tools (eg Jython) as well.