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

Posted on 12/14/2018 by Ken Gregg

If we assume that:

  1. the Python programmers are highly competent, and
  2. the C++ programmers are highly competent, and
  3. Python is interpreted (or compiled to an intermediate form that is interpreted by a runtime environment, and
  4. C++ compiles to native machine code, and has typical and apprpopriate optimizations enabled, and
  5. there is no “cheating” in the Python game engine by implementing parts of it as Python-callable libraries written in C, C++, or some other compiled-to-native-machine-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.

performance python vs c++ software development software engineering programming the c++ programming language programming in c++ c++