Update Python 3.11 a5, on Feb 19th 2022
Recently there are some posts reporting Python 3.11's aims to improve performance, for example, Guido van Rossum hopes 3.11 to double the speed, and the 3.11 alpha 5 release note also updated that it's now 19% faster. So I re-run the test again, and indeed see a quite notable improvement.
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.
| - End -
CherryPy performance on Python 2.7 / 3.9 / 3.10, analyzed by Locust load testing!