With the release of Python 3.8, this 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, 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.
Surprisingly, IronPython was not very slow in my case, it’s about 80% performance of CPython 2.7, but 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 3.x syntax.
update Python 3.9
Python 3.9 rc1, is a bit slower than Python 3.8, but still a bit faster than Python 2.7
PyPy > CPython 3.8 > CPython 3.9 (rc) > CPython 2.7 >= CPython 3.7 > IronPython
Total time: 82.7630000114
Total time: 101.15190100669861
Total time: 100.8603937625885
Total time: 102.473999977
Total time: 102.69862222671509
Total time: 124.058876038