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

Created:22-06-04 14:18    Updated:23-03-04 22:57

Update Nuitka 1.4.3, on Feb 7th 2023

Wow Surprise! The code compiled by Nuitka has outperform all CPython & PyPy in the performance test!

Nuitka compiled code > Python 3.11 > PyPy > CPython 3.10 > CPython 3.9 >= CPython 3.8 > CPython 2.7 > CPython 3.7 > IronPython

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

About a decade ago, 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, I became interested about using it to test the performance of those Python implementations, below are some notable findings:

  • Update Feb 07th 2023 - Nuitka compiled code now is the fastest! - This is a very good news for those who want to release program as executable instead of source codes. The compiled code can run on those PC without python installed, it also protects your code if you don't want others to get your source code. And, it runs even faster!

  • CPython is faster version by version, which means Python 3.11 is now fastest in CPython. But CPython 3.X was slower than Python 2.7 until Python 3.8 was released.

  • PyPy is 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(unbearable) cold startup time.

Consider that for compatiblity purpose, the testing script and the module itself was 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 -

See also:

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

An Online Pomodoro Timer is here