Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the pros and cons of the various Python implementations?

Tags:

python

I am relatively new to Python, and I have always used the standard cpython (v2.5) implementation.

I've been wondering about the other implementations though, particularly Jython and IronPython. What makes them better? What makes them worse? What other implementations are there?

I guess what I'm looking for is a summary and list of pros and cons for each implementation.

like image 308
bengineerd Avatar asked Sep 17 '08 18:09

bengineerd


5 Answers

Jython and IronPython are useful if you have an overriding need to interface with existing libraries written in a different platform, like if you have 100,000 lines of Java and you just want to write a 20-line Python script. Not particularly useful for anything else, in my opinion, because they are perpetually a few versions behind CPython due to community inertia.

Stackless is interesting because it has support for green threads, continuations, etc. Sort of an Erlang-lite.

PyPy is an experimental interpreter/compiler that may one day supplant CPython, but for now is more of a testbed for new ideas.

like image 192
John Millikin Avatar answered Nov 12 '22 21:11

John Millikin


An additional benefit for Jython, at least for some, is it lacks the GIL (the Global Interpreter Lock) and uses Java's native threads. This means that you can run pure Python code in parallel, something not possible with the GIL.

like image 22
Martin W Avatar answered Nov 12 '22 21:11

Martin W


All of the implementations are listed here:

https://wiki.python.org/moin/PythonImplementations

CPython is the "reference implementation" and developed by Guido and the core developers.

like image 3
Corey Goldberg Avatar answered Nov 12 '22 21:11

Corey Goldberg


Pros: Access to the libraries available for JVM or CLR.

Cons: Both naturally lag behind CPython in terms of features.

like image 1
Antti Rasinen Avatar answered Nov 12 '22 19:11

Antti Rasinen


IronPython and Jython use the runtime environment for .NET or Java and with that comes Just In Time compilation and a garbage collector different from the original CPython. They might be also faster than CPython thanks to the JIT, but I don't know that for sure.

A downside in using Jython or IronPython is that you cannot use native C modules, they can be only used in CPython.

like image 1
Roman Plášil Avatar answered Nov 12 '22 21:11

Roman Plášil