Python 3.11, 3.10, 3.9, 3.8, 3.7 performance vs 2.7

Created:22-06-04 14:18:    Updated:22-11-26 10:26:

Update Python 3.11.0 , on No 26th 2022

Since Python 3.11.0 was released, sometimes CPython is even a bit faster than PyPy for this test case!

Python 3.11 >= PyPy > CPython 3.8 > CPython 2.7 > CPython 3.7 > IronPython

Python 3.8 is the first time Python 3 being obviously faster than Python 2, when running a speed testing script I wrote about a decade ago.

The script did not aim to compare the speed of different versions of Python, it's written because I developed a pure Python ODBC module (pypyodbc), and I was very curious how compatible this module was 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.11.0 , on No 26th 2022

Version---- PyPy---- Python3.11---- Python3.10---- Python3.9---- Python3.8---- Python2.7---- Python3.7---- IronPython----
Total time 43.9 43.5 46.3 48.8 49.8 52.4 73.0 188.8
- End -

See also:

CherryPy performance on Python 2.7 / 3.9 / 3.10, analyzed by Locust load testing!

An Online Pomodoro Timer is here