Friday, February 27, 2015

5 Projects To Speed Up Python's Performance

Python programming language is considered as somewhat old-fashioned by many in comparison to C, Java and JavaScript. But that doesn't mean parties ditch Python as it has so many good things to think about. Instead there are some projects which can give the programming language a huge performance boost. There are two options to run Python faster on the same hardware – one is to create a replacement for the default runtime of the language and the other is to rewrite existing Python code for speed optimisations. Here are five projects which have the potential to raise the bar of Python's performance.
Python, Python programming language, Python's performance boost, projects for  Python's performance boost, 5  projects for  Python's performance boost, 5 Projects To Speed Up Python's Performance




1. PyPy

PyPy is one of the most visible options for CPython's replacement. It can also become the default one as it's highly compatible with the existing code of Python. PyPy uses just-in-time (JIT) compilation which is used by Google Chrome's V8 JavaScript engine too. PyPy 2.5, the latest version, has some more performance improvements like better support for some common libraries which are useful in boosting Python performance like NumPy. If anyone is using Python 3.x, then PyPy3 is compatible.

2. Pyston

It's a Dropbox-sponsored project which uses LLVM compiler infrastructure to speed up Python with JIT compilation. Pyston is in its early stages and supports a limited subset of Python's features. It boosts performance of some key benchmarks of the language to a certain level. Pyston will soon be ready for remote production too.

3. Nuitka

It removes Python runtime completely and finds out ways to transpile Python code to languages which can run natively at high speed. It converts Python to C++ code. As it still depends on the existing Python runtimes, its portability is limited but conversion assures speed optimisation. Nuitka is aimed to interface Python directly with C code which will boost its speed.

4. Cython

C extensions for Python or Cython is Python's superset and a version which compiles with C and interfaces with C/C++ code. It writes C extensions for Python. The only drawback is that it's not actually writing Python, else porting code which cannot be automatic completely. Cython has great advantages in relation to speed optimisations. Numerous scientific packages for Python, like scikit-learn are drawn on Cython features so that the functions are fast enough.

5. Numba

Numba is a combination of Nuitka and Cython. From Cython it takes the concept of how to speed up parts of the language like CPU-bound math which is done by LLVM. Numba's compiled functions can be specified with a decorator and Numba works in association with NumPy so that the functions are found faster. But Numba doesn't perform JITing.

According to Python creator Guido van Rossum, Python's performance issues can be traced to improper use of the language. NumPy can help in making CPU-heavy processing better via multiprocessing extensions. It can also make calls to the external C code by avoiding the Global Interpreter Lock (GIL). There is no viable replacement for GIL in Python though.

Courtesy: Java World 

1 comment: