If you are a programmer who uses Python to code every day, you might be using CPython, Cython, Jython, etc. as an interpreter. The PyPy team has released a new version, 7.1.0 which can be used as an alternative for CPython interpreter. The information on this article has been cited from the original documentation and the sources are also cited inside.
CPython or C-Extensions for Python is an optimising static compiler which provides the highest level of compatibility with Python packages as well as C extension modules. It helps you to write Python code that calls back and forth from and to C or C++ code natively at any point.
The PyPy team aims to provide a compliant, flexible and fast implementation of Python language which uses the RPython toolchain to enable new advanced high-level features without having to encode the low-level details. The main motivation for developing the translation framework is to provide a full-featured, customisable, fast and very compliant Python implementation, working on and interacting with a large variety of platforms and allowing the quick introduction of new advanced language features.
Features Of PyPy
- Speed: The main executable comes with a Just-in-Time (JIT) compiler which makes it really fast in running most benchmarks. PyPy works best when executing long-running programs where a significant fraction of the time is spent executing Python code. This is the case covered by the majority of the benchmarks, but not all of them – the goal of PyPy is to get speed but still support (ideally) any Python program.
- Memory Usage: Memory-hungry Python programs (several hundreds of MBs or more) might end up taking less space than they do in CPython.
- Stackless: PyPy can expose to its user language features similar to the ones present in Stackless Python: the ability to write code in a massively concurrent style.
- Sandboxing: PyPy’s sandboxing is a working prototype for the idea of running untrusted user programs. Unlike other sandboxing approaches for Python, PyPy’s does not try to limit language features considered “unsafe”.
The Pypy v7.1.0 includes two interpreters, PyPy2.7, which is an interpreter supporting the syntax and the features of Python 2.7 and PyPy3.6-beta, this is the second official release of PyPy to support 3.6 features, although it is still considered beta quality. Though the interpreters are based on the same codebase, this release merges the internal refactoring of Unicode representation as UTF-8. PyPy 7.0 was released in February 2019 and the new release is fully compatible with the previous one and fixed several issues and bugs raised by the growing community of PyPy users.
The PyPy release supports:
- x86 machines on most common operating systems (Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD)
- big- and little-endian variants of PPC64 running Linux,
- s390x running Linux
The new features included in this bug-fixed release are mentioned below:
- As mentioned earlier, it includes two different interpreters PyPy 2.7 and PyPy 3.6
- Merges with UTF-8 to give a nice speed bump
- The ability to use the buffer protocol is improved with ctype structures and arrays
- The CFFI backend has been updated to version 1.12.2
- Improve register allocation in the JIT by using better heuristics
- Correctly initialized the d_type and d_name members of built-in descriptors to fix a segfault related to class methods in Cython
- Added copying to zlib
PyPy has been claiming that it is faster than CPython and there has always been the controversy of using PyPy over CPython. Speed has always been one of the major factors for programmers. PyPy undoubtedly runs faster on some CPU-heavy workloads but sometimes it lacks to work not so faster for Python scripts. By overcoming all the challenges in PyPy, it can certainly become the faster interpreter. PyPy 7.1.0 is available to download from here.