Pypy is an alternate implementation of the python programming language. Pypy started out as a python interpreter written in python. It is aimed at being compatible with cpython and currently with experimental compatibility for CPython C API extensions.
Pypy originally refered to two things. one the python interpreter and Rpython Translation toolchain but currently pypy is always used to refer to the python interpreter. The translation framework is always refered to as the Rpython Translation Framework.
It is the distinct features embedded in pypy that give your python programs the magical performance. Lets have a look at some of them.
Pypy Distinct Features
The pypy intepreter offers a couple of distinct features namely;
- Memory Usage
- Stackless python features
Pypy is magically faster due to its high performance Just-in-time compiler and garbage collector.
It is therefore faster for programs that are JIT susceptible. This means that pypy may not always run faster, it may be for pure python code but actually run slower than Cpython where the JIT cant help.
pypy may also not be as fast for small scripts that do not give the Just-in-time compiler enough warm up time.
I ran this code on pypy and on normal python and the results show pypy is actually faster. I will go on share the outcomes below;
Alot of benchmarks have shown pypy performing better than Cpython and its not getting slower with time. Each new version of pypy is faster than its predecessor. The pypy team have shared good insight at their speed center.
Good news is pypy is compatible with most of the python Libraries.
- Beautiful Soup
Pypy has Experimental support for Extension modules through cpyext. It can run most C extensions these days.
Memory-intensive python programs take lesser space than when running on pypy . However this may not be the case always though due to some details.
Stackless python Features
Pypy exposes language features similar to the ones present in stackless python.
Differences between Cpython and Python
Lets take a look at pypy and a reference python implementation called cpython.
“If you want your code to run faster, you should probably just use PyPy.” — Guido van Rossum (creator of Python)
It is easy to install
`sudo apt-get install pypy`
`sudo brew install pypy`
There is rich Documentation on installation for windows.
Check these out for more pypy inspiration