Sunday, 16 March 2014

Why different flavors 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 thesepackages.

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.

Name

Description

PyIMSL Studio

A commercial distribution for numerical analysis – free for non-commercial use

Author :

About Techdarting:

This technical blog aims at providing information and insights about different technologies from areas such as Parallel computing, Linux, Android and Web technologies to name a few. We at Techdarting are experts in varied parallel computing paradigms such as MPI, OpenMP, CUDA, OpenCL etc., as well as Linux and Web programming enthusiasts.

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?