Features Tutorials

The story behind Jython support in PyCharm

Giacomo Lacava recently wrote a blog post describing his not very good experience with Jython support in PyCharm. I’d like to explain what the situation actually is.

First of all, PyCharm currently supports Python versions starting with 2.4. This means that PyCharm’s own components written in Python use language features of Python 2.3 and 2.4, and simply will not run with Jython 2.2. With Jython 2.5, things like loading the list of library paths and completion for the standard library (which Giacomo had problems with) should work with no problems.

Second, it’s true that we do not support parsing jar files in PyCharm. When PyCharm was initially designed, the Java support in IntelliJ IDEA was a monolithic component, and we had the choice of either including it all or leaving it all out. Including it would mean that we would have a Python IDE that could do, say, an “Introduce Parameter” refactoring for Java but not for Python. Which would be really, really weird. So we decided to leave it all out.

On the other hand, the IntelliJ IDEA Python plugin can rely on the Java support in IntelliJ IDEA itself, and it contains all the necessary logic to support Java/Python interop. The plugin can resolve imports from Python files to Java code, perform cross-language refactorings, auto-import Java classes in Python code, etc. And as far as we know, it provides a better Jython development experience than any other IDE.

The good news is that, since that time, our Java support has become more modular, and now we have the option to include just enough of it in PyCharm to support Java/Python interop but not anything more. Therefore it’s possible that a future version of PyCharm will have the same degree of Jython support as the IntelliJ IDEA Python plugin currently has. However, we’re still not sure if there’s enough of a target audience for this functionality. So if you’d like to have this, please let us know.

image description