一款Windows PC端待办事项软件


Python 3.10, 3.9, 3.8, 3.7 performance vs 2.7


[Updated Aug 9th, 2021] Python 3.10 is the fastest, and the new King of Speed of CPython.

Python 3.8 is the first time a Python 3.X version clearly beats Python 2.7, when running a speed testing script I wrote about a decade ago.

This is not a script aims to compare every function aspect of different versions of Python, it's written because I developed a pure Python ODBC module (pypyodbc), and I was very curious how bad, or fast, this module run on different implementations of Python, including: CPython 2.X, CPython 3.X, PyPy and even IronPython.

While on all of the above-mentioned interpreters, the pure python module could run normally, until Python 3.8, the performance rank was always being: PyPy > CPython 2.7 > CPython 3.X > IronPython

Some interesting findings are:

  • PyPy is obviously the fastest, and one can see it’s always speeding up seconds by seconds when running the script.

  • IronPython was about 3 times slower than Python 2.7 in my case, with a quite noticeable startup time.

  • Till Python 3.8, CPython 3.X was slower than Python 2.7.

Since Python 3.8 was released:

PyPy > CPython 3.8 > CPython 2.7 > CPython 3.7 > IronPython

It’s finally a litter bit faster than Python 2.7. Consider that for compatiblity purpose, the testing script and the module itself is written in a way both 2.X and 3.X could run, but more friendly to Python 2.7, the performance of 3.x interpreter should be even better if codes are written in native 3.x syntax.

Update Python 3.10 rc1, on Aug 9th 2021

Python 3.10 is quite obviously and stablely faster than other version of CPython during several rounds of testing.

PyPy > PyPy 3.10 > CPython 3.9 > CPython 3.8 > CPython 2.7 >= CPython 3.7 > IronPython

When I did the test when Python 3.9 is still in RC status, it's more often slower than 3.8, but now it's a bit faster than 3.8


PyPy

    Total  time: 42.1

Python3.10

    Total  time: 46.3

Python3.9

    Total  time: 48.8

Python3.8

    Total  time: 49.8

Python2.7

    Total  time: 52.4

Python3.7

    Total  time: 73.0

IronPython

    Total  time: 188.8




An IT Project Manager's Blog

An Online Pomodoro Timer