What can Python do that Jython cannot?

I need a flexible structure, and I would like to try to enter the code in different places, just to change the behavior on the fly.

Since this is a Java project, and I'm mostly limited to interfaces and playing with the implementations behind them, I thought I could run Jython and see what it could bring to the table.

I mean, eval() is a powerful function, and I could add the code as a string and evaluate it, at least in Python, and the question arose there, since it mostly compiles in Java ...

What limitations exist for Jython compared to Python? What can I do in Python, what can I not do in Jython?

+4
source share
2 answers

As noted in a previous post, you really want to compare CPython with Jython. As noted earlier, the stable version of Jython is 2.5.3 with an alpha version for 2.7. This means some features are missing in Jython. For example, ordered dictionaries, counters, and named tuples were added to the Collections package with 2.5. With Jython, you cannot use many third-party Python libraries, such as NumPy, SciPy, GeoDjango, Lxml, or anything that uses C extensions.

Jython, on the other hand, has several advantages that you cannot find with CPython. With Jython, you can deploy Django to a standard Java server (e.g. Tomcat, WebLogic, etc.). You can call existing Java classes from Jython code.

+4
source

Consider comparing jython with cpython as they are both pythons, but one is implemented in c and the other in Java. Thus, cpththon startup time is much faster. If you check the startup time for each to run the hello world example, cpython executed the code about 50 times faster. Stability Jython currently uses Python 2.5, which is much older than the current python 2.7 in the 2nd series, and they do not have a python3 implementation. That way you would miss some of the features there.

 $ time jython -c "print 'hello'" hello real 0m1.641s $ time python -c "print 'hello'" hello real 0m0.026s 
+1
source

Source: https://habr.com/ru/post/1441607/


All Articles