Recent Blogs

PyPy: One Of The Widely-Used Python Implementations

A Step-By-Step Guide For A Quick Firebase Hosting | A Service By Google

Python is a dynamically typed programming language developed by Guido Van Rossum. It is put into use on various applications like web and android development, game development, software development, etc. 

Python possesses various advantages over other languages of a similar kind. Like it is easy to learn and implement, possess easy syntax, error handling is easy, etc. Due to these reasons, it’s the first choice for various developers. 

Usually, when we talk of Python, we talk about its implementation. To understand this, consider ‘implementation’ as an environment where Python code is executed. 

There are a vast number of Python implementations. Some are CPython, PyPy, IronPython, Jython, CLPython, Pyston, IPython, etc. Out of these, the first one i.e. CPython is the default implementation. 

So, without further delay, let’s start today’s discussion on the most favorable Python implementation, PyPy. 


As mentioned above, CPython is the default or standard implementation of Python. PyPy is an alternative to CPython. Now, you must be thinking of why it’s advisable to use PyPy, especially today. So, here’s the reason. 

PyPy is a JIT compiler while CPython is an interpreter. Hence, PyPy is faster than CPython in terms of execution and performance. It can execute a Python program 7.6 times faster than CPython. Some codes can be quickened by almost 50 times. PyPy supports Python 2.7.13 and Python 3.6.9. 

Also, the creator or Python also said that “If you want to run your code to run faster, use PyPy”. PyPy is written in RPython, which is another subset of Python. 

How PyPy works?

In this section, I am going to discuss the working mechanism of PyPy. 

Since PyPy uses JIT (Just-In-Time) compilation, it uses the optimization techniques used by other compilers. It analyzes the Python program and determines the information of each object created/used in the program. And, this information is used for speeding up the execution process. 

PyPy optimizations are handled and improved at the runtime itself. Also, for generating a faster code in PyPy, you can use PyPy’s command-line options. This works for special cases but most of the time, it is not necessary. 

It deals with garbage collections differently from CPython. If you want any information regarding PyPy’s JIT behavior at runtime, you can use a module pypyjit to obtain that. 

In case, any function or module performs poorly with JIT, you can use pypyjit to get detailed information regarding the function. 

Another special module, ___pypy___ provides information regarding features specific to PyPy. So, this is everything about PyPy.

Limitations of PyPy

PyPy too possesses some limitations uncommon to CPython. Like, sometimes it remains ineffective for certain programs. It is still not a proper replacement for CPython. 

Other limitations of PyPy are:

PyPy works well with only pure Python apps

This is another limitation of PyPy. It works with only pure Python apps i.e. apps written entirely in Python. So, Python packages that involve any non-Python library don’t go well with PyPy. 

But recently, PyPy developers have worked upon this issue. Now, PyPy is compatible with a lot of Python packages that include some C extensions. So, today, NumPy is compatible with PyPy. 

However, if you want maximum compatibility with Python packages with C extensions, use CPython.

PyPy works well with only long-running programs

With PyPy, long-running programs are more benefited from PyPy optimizations than one-and-done programs. Longer the program runs, more information PyPy can gather and more the optimizations it can make. 

PyPy doesn’t do ahead of time compilation of Python code

Python is not a compiler for Python. It just compiles a Python code. So, it can’t do ahead of time compilation of it. If you want to compile a Python code that can run as a standalone app, use CPython or Numba.

Features of PyPy

Following are the features of PyPy:

  1. PyPy is capable of executing a Python code very quickly than any other implementation. It is true with even complex codes, not just the basic ones.
  2. Even large codes take less memory space in PyPy than in CPython.
  3. It supports the Stackless mode. It helps programmers simplify thread-based programming. In this way, the code is simplified using threads. This also makes readable.
  4. Current PyPy version is compatible with all the operating systems.

So, with this, the blog ends. In this blog, I discussed today’s widely used Python implementation, PyPy. How it works, its limitations and some features. There are many other implementations of Python like CPython, IronPython, Jython, etc. 

Share this