简体   繁体   English

Jython比Python快吗?

[英]Is Jython faster than Python?

I'm trying to get a little program to send hex over RS232. 我正在尝试获取一个小程序以通过RS232发送十六进制。 From what I've seen Python is a very good language to do this with. 从我看到的内容来看,Python是一种很好的语言。

I learned it 3 years ago in an into to compsci course as a freshman in high school, and the syntax is amazing. 我3年前在高中一年级时就读到compsci课程中学习了它,语法令人惊叹。 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#. 但是,从大一开始,我就一直在使用Java,Objective-C(上帝保佑我可怜的灵魂)和C#。

Anyway, I would like to use Python for learning how to use serial communication. 无论如何,我想使用Python学习如何使用串行通信。 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?) 现在,我再次查看它,我“发现”了Jython,它看起来像是python,但是它使用Java运行时(对吗?)

Will I be happier using something such a Jython rather than good-old Python? 我会更喜欢使用Jython之类的东西,而不是旧版本的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 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). 就像你说的,Jython是Python的JVM的基础上实现的,看到的Jython至于我可以告诉大家,它通常较慢比CPython的(这就是你所说的好老的Python)。

The real advantage of Jython is that it can import and use any Java class (and the same applies for .NET and IronPython). Jython的真正优势在于它可以导入和使用任何Java类(.NET和IronPython也是如此)。

For one of my projects, I decided to benchmark Jython, CPython and Pypy using the project's innermost loop. 对于我的一个项目,我决定使用该项目的最内层循环对Jython,CPython和Pypy进行基准测试。 Jython was a little slower than CPython with Cython, but faster than unaugmented CPython. Jython比使用Cython的CPython慢​​一点,但比未增强的CPython快。 In general, Jython is respectably fast for long processes, but it takes a while to get started. 通常,Jython对于较长的过程来说速度很快,但是开始需要一段时间。

If you want to use Jython, go ahead and use Jython. 如果要使用Jython,请继续使用Jython。 Python != CPython anymore. Python!= CPython了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM