Comparison of libraries for interaction between java and Python

In the production backend we have to do lots of calculations. Python has been used in the production code. Python C extended library like numpy gives speed which is little less than actual C code, but gives the benefit of less code ,easy maintenance as compare to other languages like C++/java . But python’s libraries are not as rich as of Java. Java is used worldwide and it has a large collection of libraries. So if we could use the benefits of java i.e. Large collection of libraries can avoid the long code of java by using python.

The following open source libraries are available for communication between java and python:

Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. But as we need to use Python C-extensions like NumPy we can’t use Jython for our project.

JEP (Java Embedded Python) embeds CPython in Java. Its main thing is JEP class which contains all the functions like runScript, eval which has been implemented through JNI.

JPype allows python programs full access to java class libraries. This is achieved not through re-implementing Python, as Jython/JPython has done, but rather through interfacing at the native level in both Virtual Machines.

Py4J is a hybrid between a Remote Procedure Call and Java Virtual Machine to run a Python program. Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine.

I made a detailed comparison including pros, cons, memory usage, speed etc.