Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Approaches Considered

JPype

Official Documentation : - https://jpype.readthedocs.io/en/latest/

JPype is a Python module to provide full access to Java from within Python. Unlike Jython, JPype does not achieve this by re-implementing Python, but instead by interfacing both virtual machines at the native level. This shared memory based approach achieves good computing performance, while providing the access to the entirety of CPython and Java libraries. This approach allows direct memory access between the two machines, implementation of Java interfaces in Python, and even use of Java threading. JPype user guide is available in this link : https://github.com/jpype-project/jpype/blob/master/doc/userguide.rst

...

Py4J is a library that enables Python programs to dynamically access Java objects in a Java Virtual Machine (JVM). It allows Python code to interact with Java code and vice versa, making it useful for integrating Python and Java programs. Py4J includes a gateway that connects the Python and Java programs, and allows for the exchange of data and calls between the two languages. 

Py4J uses sockets to communicate between the Java and Python programs. When a Py4J gateway is created, it starts a server socket that listens for incoming connections from the Python program. The Python program can then connect to this socket and send commands to the Java program via the socket connection.

The Java program, in turn, sends the results of these commands back to the Python program via the same socket connection. This allows for a two-way communication between the Java and Python programs.

Py4J uses the socket connection to pass data and method calls between the two languages, and it takes care of the details of serializing and deserializing the data, so that the two programs can understand each other.

Since it uses sockets to communicate parallel execution in same vm will be difficult