相关文章推荐
豪气的墨镜  ·  module 'torch' has no ...·  3 月前    · 
热心肠的山羊  ·  java - How to solve ...·  1 年前    · 
完美的排球  ·  python - How to read ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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)?

Is this 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?

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.

Thanks! I guess what I am looking for is an equivalent of the Graal JS Maven package for Python: mvnrepository.com/artifact/org.graalvm.js/js . At the moment it does not seem to be available: github.com/graalvm/graalpython/issues/96 pintoch Aug 6, 2019 at 13:05 I'd just like to add that "you're not missing on anything" isn't necessarily true! GraalVM has a JDK11 distribution but it lacks ZGC (which is critical for many workloads). shavit Apr 5, 2020 at 7:13 If you wanted to run any Truffle language on stock JDK with Truffle compilation enabled, then you cannot use any GC that is not supported by the GraalVM compiler. So even on JDK11 you cannot use ZGC with Truffle languages. Hopefully, those GCs will become supported by the GraalVM compiler. Steves Apr 8, 2020 at 16:34

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .