Search code examples
javapythonjythonlanguage-features

What can Python do that Jython cannot?


I'm in need of a flexible framework and would like to try to inject some code in different places of it just to change behavior on the fly.

Since it's a Java project and basically I'm limited to interfaces and playing with the implementations behind those I thought I might give Jython a run and see what that might bring to the table.

I mean, eval() is a powerful function and I could add code as string and have it evaluated, at least in Python and there popped the question since it basically compiles to Java...

What limitations are there for Jython as compared to Python? What can I do in Python that I can't do in Jython?


Solution

  • As a previous post noted, you are really looking to compare CPython with Jython. As previously noted, the stable version of Jython is at 2.5.3 with an alpha version for 2.7. This means there are certain features missing from Jython. As an example, ordered dictionaries, counters, and named tuples were all added to the Collections package since 2.5. With Jython you cannot use many 3rd party Python libraries such as NumPy, SciPy, GeoDjango, Lxml, or anything that uses C extensions.

    On the other hand, Jython has a few benefits you cannot find using CPython. With Jython you can deploy Django on a standard Java server (e.g. Tomcat, WebLogic, etc...). You can call existing Java classes from Jython code.