Will a game engine in Python be slower than one written in C++?

If we assume that:

  1. The Python programmers are highly competent, and
  2. The C++ programmers are highly competent, and
  3. Python is interpreted, and
  4. C++ compiles to native code, and has typical optimizations enabled, and
  5. There there is no “cheating” in the Python game engine by implementing parts of it as Python-callable libraries written in C or some other compiled-to-native-code language, and
  6. The two game engines implement the exact same requirements,

Then, yes, the Python engine will be slower than the C++ engine. There is a reason why many Python-callable libraries and extensions are written in C or C++.

The Python source code would likely be smaller than the C++ source code, but source code size is irrelevant when considering run time performance. The Python engine will likely occupy a lot more memory (which can affect performance, depending on the environment), and the interpretation of Python at run time will typically be many times slower than the execution of native code generated by the C++ compiler.

Leave a Reply