CPython vs PyPy vs Pyston

Introduction

Recently I've been seeing articles about Pyston 2 online. 20% faster than Python, "Pyston 2.0" is now available

It was a Python processing system that I had never heard of before, so I installed it and compared the speed with other processing systems.

I ran it in the following environment.

Windows 10 Home 19041.630
Ubuntu-20.04 on WSL
Python 3.8.5 (Official, below CPython)
Python 3.6.9 (PyPy 7.3.1)
Python 3.8.2 (Pyston 2.0.0)

I used WSL because Pyston is currently only available on Ubuntu.

This time, I will omit each installation method. Please install by referring to each homepage.

program

Execute timetest.py in Python, call _timetest.py in each processing system from the inside, and get the result using subprocess.

# timetest.py

import subprocess

binaries = ["python3", "pypy3", "pyston"]

for binary in binaries:
    out = subprocess.check_output([binary, "./_timetest.py"])
    print(out.decode())

# _timetest.py

import time, sys

def main_func(number):
    big_array = []
    one_tenth = number // 10
    for i in range(10):
        big_array.append([])
        little_array = big_array[i]
        for j in range(one_tenth):
            data = i * one_tenth + j
            little_array.append(data)
    return big_array

def clock(number):
    start = time.time()
    _ = main_func(number)
    result = time.time() - start
    rounded = round(result, 3)
    return rounded

number = 40_000_000
version = sys.version

binary = "PyPy" if "PyPy" in version else "Pyston" if "Pyston" in version else "CPython"
result = clock(number)

print(f"{binary}\t:{result}[sec]", end="")

Execution result

I was looking forward to seeing how fast Pyston was, ** Well, the result is that it's slower than CPython. ** **

First place was PyPy, which was reasonably expected, but it never turned out that Pyston was slower than CPython ...

CPython PyPy Pyston
3.415[sec] 0.472[sec] 4.088[sec]

Of course, I think it goes well with this program, but it's a shame.

finally

Although it was a disappointing result, PyPy in 1st place is more than 7 times faster than others. If you decide to use it now, PyPy has a lot of manuals.

It seems that there are still many improvements, so I'd like to expect it in the future.

It's encouraging to get a star: relaxed: Thank you for reading.

Recommended Posts

CPython vs PyPy vs Pyston
Speed comparison between CPython and PyPy