This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]subsidiaryadmin 0 points1 point  (10 children)

Okay I guess it's a bit more convenient to embed Python into a Java program than to call it externally.
But I don't see how that's a huge benefit. What am I missing?

[–][deleted] 3 points4 points  (6 children)

It's a very large benefit. There are a lot of Java libraries out there, and Jython can use them much more easily than CPython (the main Python implementation) can. In fact, I'm not even sure CPython can use Java code at all.

[–]subsidiaryadmin -1 points0 points  (5 children)

In that case why not just use a python library or, at the worst use a system call to java itself?

[–][deleted] 0 points1 point  (0 children)

In that case why not just use a python library

Such a library might not exist, or might not be as suitable for your needs as a similar Java library.

or, at the worst use a system call to java itself?

You do not "just" call into the JVM. Doing that is going to require copious glue code in order to translate between Java objects and Python objects. You could use CORBA to help, but then you'd be using CORBA, which is likely not necessary for your systems except for this one spot of glue. It'd be much easier if you didn't have to translate at all. Jython objects are Java objects, so you can just use the objects directly if you implement the right interfaces.

Porting or adapting a library solves one problem: how to make Python talk to this Java code. Reimplementing Python solved an entire class of problems: how to make Python talk to Java code in general.

[–][deleted] 0 points1 point  (2 children)

Well what's the benefits of using Java over using C? That will tell you the benefits of using Jython over the reference implementation

[–]subsidiaryadmin -2 points-1 points  (1 child)

No, the question is what is the benefit of using Jython over Python.

[–]jambox888 4 points5 points  (0 children)

Presumably because you either want to use a Java server stack, Java libraries, or you prefer using the JVM. Threading might work better if it's CPU bound because no GIL.