Sunday, 16 March 2014

Why different flavors of Python

Posted by Unknown

Why different flavors of python, Python, Implementations of Python

    We always want different flavors in everything, don’t we? As they say varieties add spice to life. So python need not be exception to this. How many times have you wondered why there is python,Cpython, Jython, IronPython and many more .*ython, that is, these different flavors of python. Lets start understanding it.

1) Cpython:    The base of all these implementation is Cpython or more formally known as python (Yeah its True your Python is actually Cpython). Cpython is de-facto reference Python implementation. Some implementations may extend behavior or features in some aspects or re-implementations language that do not depend or interact with the CPython runtime core but reuses the standard library implementation of Cpython. Since Cpython is standard to implement python someone can implement it to be compiled or to be interpreted according to their requirements.
    It is written in C and is a bytecode interpreter. Your bytecode is executed on CPython Virtual Machine. That is why I used to say foolishly that Python is interpreted language which indirectly is True about Cpython not for all python variants. 
    Python website categories all other implementations  as Alternative Implementations(Rightly so).

2) Jython:    Jython,earlier known as Jpython (or known to be successor of Jpython) is an implementation of the Python programming language which is designed to run on the Java Platform. It has compiler which compiles your python code into Java bytecode. Stable releases of compatible python(latest) is still not available.
    But question is why we need Jython? Jython adds compatible libraries of python that are really helpful for developers(Now you have both java and Python libraries at one place, isn’t that great?) and make it more powerful language. You can look at this as a way to glue together and leverage an existing collection of class libraries. Some find syntax of python concise and quicker.
    For a instance you want to write HTTP GET request in java,how much code you have to right? and when you know urllib in python isn’t things get easier?

3) IronPython:    IronPython is another implementation of the Python targeting the .NET Framework. It is entirely written in C# and runs on .NET virtual machine(That is nothing but CLR). Again you can import C# classes into ironPython. IronPython can use the .NET Framework and Python libraries(again isn’t that great ), providing Python developers with the power of the .NET framework or providing .NET developers with power of scripting.
    Current version targets Python 2.7.There are some known compatibility issues with Cpython libraries.  

4) Pypy:    Pypy is actually bit different than other implementations its primary focus is to overcome drawbacks(so called) of python. It is a Python interpreter and just-in-time compiler. It is written in Python itself. Actually PyPy is written in a language called RPython, which is suitable for writing dynamic language interpreters (and not much else). RPython is a subset of Python and is itself written in Python. According to claims made by pypy its around 6 times faster than Python.
    While JIT is main goal, it also focuses on efficiency and compatibility with the original CPython interpreter. Its implementation is highly compatible with Cpython.
    There are many talks about pypy being the future of the languages. For some JIT may not that useful for small scripts with non-repeatable code. Lets wait and watch for more of Pypy, future is yet to come.

5) Stackless Python:    If you ever tried threading in python then you will understand what and why Stackless Python. Stackless Python is a reimplementation of traditional python and its key point is lightweight threading. You can say its branch of CPython supporting microthreads.
    Stackless python's key concept is tasklets which is nothing but tiny taks. It allows you to run hundreds of thousands of tasklets in a single main thread. Tasklets run independently on CPU and can communicate with other via Channels. Channel is sort of manager that take all the responsibility to control suspension and resuming of tasklets. You can also control scheduling of tasklets and not to mention serialization with pickle can be done for tasklets.
    Stackless is claimed to be completely compatible with Standard Python but some issue been reported when using with PyQT.

6) ActiveState ActivePython:    ActivePython is a CPython distribution by company named ActiveState. It is commercial implementation and is proprietary. Key points are support and reduced risk for commercial application and some additional modules(Haven't tried it yet).

7) Pythonxy:    Firstly its pronounced as Python x-y and mostly written as Python(X,Y). It is nothing but a scientific Python distribution. Python added with scientific and engineering related packages is your python(x,y). Its also includes Qt for GUI and Spyder IDE.
    Why use it when i can manulally install packages i will be needed. No doubt you can add any package to your python but what if dish is served to you ready made with these packages.

8) Portable Python:    How about having python language pre-configured,any time, any where,run directly from any USB storage device. It is what Portable python is. Its for Windows OS. You just need to extract it to your portable storage device.

9) Anaconda Python:    In short words you can say it is distribution for large-scale data processing, predictive analytics, and scientific computing. This implementation basically focuses large scale of data.

Some other names to mention here. Some of them are language bindings e.g. RubyPython  some are VMs e.g. Brython.

PyIMSL Studio
A commercial distribution for numerical analysis – free for non-commercial use
Enables writing C extensions for the Python easy,  calling C functions and declaring C types variables.
A bridge between the Ruby and Python interpreters. It embeds a running Python interpreter in the Ruby applications.
A portable scientific Python distribution for Windows. same as python(x,y)
Python 3000 (Py3k)
Its nothing but your Python 3
Conceptive PythonSDK
For development and deployment of desktop applications
Language bridge for Python and Objective-C.
Enthought Canopy
Commercial scientific python implementation.
Goal is to replace Javascript with Python, as the scripting language for web browsers. Python Vm written in JS. Python 3.
Combines all the advantages of Qt and Python.


Author :

Amit Khomane


  1. Thank you for the summary. The list is longer. There are also Python interfaces to just about everything that is important (e.g. pymatlab).

    Among others, for microcontrollers there is at least micropython and pymite as well as some older ones.

    1. Yes, the list is really long. I preferred to list out only few of them. I do appreciate your inputs, pymite is interesting and new thing to me.

  2. Why CPython is still the far most famous implementation as the others have problems with libraries written in, e.g., C or C++. Numpy, Scipy, matplotlib and all those nice libraries built on top of them will not work there?

    1. Yes, that's why CPython stands tall among all implementations. This is because people always takes CPython as reference for creating new libraries, not taking into consideration other implementations.

  3. I use WinPython cause it's portable and already includes Spyder IDE, win32com and Qt. Though processing a couple of millions of row from MS Access with Cpython isn't very fast. Maybe i need pypy?..