Quickstart
Python4j Key features and brief samples.
Overview
try(PythonGIL pythonGIL = PythonGIL.lock()) {
try(PythonGC gc = PythonGC.watch()) {
//execute your code
}
}Python Executioner
try(PythonGIL gil = PythonGIL.lock()){
try(PythonGC gc = PythonGC.watch()){
List<PythonVariable> inputs = new ArrayList<>();
inputs.add(new PythonVariable<>("x", PythonTypes.STR, "Hello "));
inputs.add(new PythonVariable<>("y", PythonTypes.STR, "World"));
PythonVariable out = new PythonVariable<>("z", PythonTypes.STR);
String code = "z = x + y";
PythonExecutioner.exec(code, inputs, Collections.singletonList(out));
System.out.println(out.getValue());
}
}catch (Throwable e){
e.printStackTrace();
}Last updated
Was this helpful?