days
0
-10
-2
hours
-1
-5
minutes
-5
-2
seconds
-1
-6
search
Fast, flexible Python

PyPy v7.1: Can this Python interpreter make your code faster?

Sarah Schlothauer
python
© Shutterstock / Deb Davis

PyPy’s new update adds a few new tweaks and two new interpreters. While CPython is the standard implementation of Python, PyPy is a great alternative that can make your Python code run even faster and lighter. See what’s new and what advantages it has.

Python programmers, rejoice! Over the weekend, PyPy got a new release! v7.1 includes two different interpreters and a few changes.

Before we get into the new additions to PyPy, let’s take a step back and see what it is and all of its useful features. CPython is the standard implementation of Python, so why should you switch to an alternative? PyPy gives several reasons why it might be worth your while to give it a go.

Faster Python

PyPy is a fast, compliant Python interpreter that’s as fun to use as it is to say out loud.

The team’s mission statement reads:

We aim to provide a compliant, flexible and fast implementation of the Python Language which uses the RPython toolchain to enable new advanced high-level features without having to encode the low-level details. We call this PyPy.

What advantages does it have and what sets it apart from CPython?

Key features:

  • Speedy performance: The speed center explores how fast its performance is and how it’s changed with each new version. Compared to CPython, it is (on average) 7.6 times faster. If speed is critical to your code, give PyPy a test and take advantage of its Just-in-Time compiler. (Bear in mind that while PyPy is an excellent tool, it isn’t magic. It won’t be able to speed up your C functions, only your Python code, and only if it has a run-time of over several seconds.)
  • Lower memory usage: Programs in CPython taking up a lot of space? They might take up less space in PyPy. (This depends on several factors, see what the improvements require.)
  • Default stackless feature support: Write code in a massively concurrent style.
  • Code compatibility: Keep up to date with what versions of Python and library nodules PyPy is compatible with. All your favorite popular Python libraries like twisted and django are supported.
  • Sandboxing: This is currently in its working prototype phase, so tread with caution, you might be on your own fixing some issues.

SEE ALSO: Reahl: A web application framework purely in Python

Welcome v7.1

What’s new in the v7.1 release? It’s actually two releases in one, thanks to the hard work of the small contribution team.

  • Two different interpreters: PyPy2.7, which is an interpreter supporting the syntax and the features of Python 2.7 and PyPy3.6-beta, which supports 3.6 features.
  • Merged unicode-utf8
  • Improved ability to use the buffer protocl with ctype structures and arrays
  • CFFI backend updated to version 1.12.2.

PyPy currently supports x86 machines on most operating systems.

SEE ALSO: Functional programming goes tropical with Coconut, a powerful Pythonic programming language

Download the latest version. (Should you install numpy or numpypy? Follow the FAQ for more info on how to install PyPy.)

The repository is available on BitBucket. Slither away to the repo and see what it can do for your code.

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of