Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Jython faster than Python?

I'm trying to get a little program to send hex over RS232. From what I've seen Python is a very good language to do this with.

I learned it 3 years ago in an into to compsci course as a freshman in high school, and the syntax is amazing. It's pretty much like pseudo code.

However ever since freshman year I have been working with Java, Objective-C (god bless my poor soul), and C#.

Anyway, I would like to use Python for learning how to use serial communication. Now that I am looking at it again I have "discovered" Jython which appears to be python but it uses the Java run time (is that correct?)

Will I be happier using something such a Jython rather than good-old Python? Or for such a "little" task as sending hex over serial ports will I not notice a difference?

If you are going to downvote my question can you please at least tell me why? -- thank you.

like image 826
Sponge Bob Avatar asked Jun 28 '12 18:06

Sponge Bob


People also ask

Is Jython slower than Python?

Python's performance depends on its implementation; Jython tends to be slower than CPython, while PyPy is significantly faster.

How is Jython different from Python?

Jython and Python are two versions of the same language, used for different contexts. Jython is a Java implementation of Python, which, in a nutshell, means it's Python running on a Java Virtual Machine (JVM) environment. It writes like Python, but it can access the full potential of Java libraries.

Why would you use Jython?

Interactive experimentation - Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.

Does Jython run on JVM?

Jython is a version of the Python programming language that runs on the Java platform. It allows users to write programs in Python and compile them to Java bytecodes that run directly on a Java Virtual Machine, or JVM. It's similar to otherJVM languages like; Scala, Kotlin, Groovy, or Clojur.


2 Answers

For one of my projects, I decided to benchmark Jython, CPython and Pypy using the project's innermost loop. Jython was a little slower than CPython with Cython, but faster than unaugmented CPython. In general, Jython is respectably fast for long processes, but it takes a while to get started.

If you want to use Jython, go ahead and use Jython. Python != CPython anymore.

Here's the comparison _for_one_microbenchmark_: http://stromberg.dnsalias.org/~strombrg/backshift/documentation/performance/index.html

like image 152
user1277476 Avatar answered Sep 28 '22 17:09

user1277476


Like you said, Jython is Python implemented on top of JVM, see Jython As far as I can tell, it's usually slower than CPython(which is what you call the good-old python).

The real advantage of Jython is that it can import and use any Java class (and the same applies for .NET and IronPython).

like image 28
Diaa Sami Avatar answered Sep 28 '22 16:09

Diaa Sami