Python2.0vsPython3.0

Also, the two biggest problems (IMNSHO) with Python 2.x don’t apply to Jython:

  1. Python2 plays fast and loose with character encodings, with strings implemented with 8-bit bytes. Python2 uses byte arrays as strings and vice versa throughout the implementation, with much associated grief for file and pipe access when trying to handle internationalization. Python3 separates byte arrays from strings throughout. Jython’s strings are Java strings, which are implemented with 16-bit short integer code points. Jython already has separation between byte arrays and strings, particularly when leveraging Java classes directly.

  2. Python, both 2.x and 3.x, suffers from poor threading performance, due to the existence of the global interpreter lock. Python3 works around this architectural problem with the widespread adoption of async/await event-driven functional structures. It doesn’t help computationally intensive threading tasks, but is astonishingly effective for I/O-bound tasks. Jython’s threads simply wrap Java threads, and the Java implementation of Jython’s core python data types makes use of concurrent base types and synchronization to avoid the need for the global interpreter lock. Jython is fully multithreaded in a way that Python2 will never be, and Python3 isn’t yet (and maybe never).

That said, Python3 has a number of language improvements that would be wonderful to have in Jython.

1 Like