Using GraalPython as a Jython replacement

Question:

I wonder if it is possible to use GraalPython as a Java library to interpret Python code on a standard JVM. If so, would it be a good choice to replace Jython (which only supports Python 2.7)?

It would be great if that was possible without importing the entire GraalVM project. I expect only Truffle and the Python interpreter built on top of it should be necessary.

If this is not possible, are there any good Java implementations of Python 3 available?

Asked By: pintoch

||

Answers:

You should be able to run any GraalVM language on any JDK as their are just Java programs. However, the performance will be affected a lot. Moreover, languages like python consist of additional resources (standard library files, etc.) that you would have pull from GraalVM too.

This document about GraalVM JavaScript discusses this in more detail and describes how to run GraalVM JavaScript on stock JDK without compromising the performance. Some of it can be applicable to GraalPython.

https://github.com/graalvm/graaljs/blob/master/docs/user/RunOnJDK.md

Tl;dr: it will be much easier to use GraalVM. It’s full JDK distribution. You are not missing on anything. If you can’t, there are some ways.

Answered By: Steves

GraalVM has a document about migrating from Jython: https://github.com/oracle/graalpython/blob/master/docs/user/Jython.md

Note that I haven’t tried it and have no idea how ready it is for use.

Answered By: Aleksandr Dubinsky
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.