Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I intend to write a game in Python and, later, if needed, offload any performance-critical sections of code to C++. I want to use Python basically because I am really familiar with the language and I find writing game logic in it to be easier. However, unlike game logic which runs at a constant rate(50-60 ticks/s), you usually want to do rendering as fast as the hardware allows. Given this, the renderer will probably be the first thing to optimize out.


  1. The game is overall written in Python, the game loop as well, the renderer is written in C/C++ and called from Python

  2. The game is written in Python, the loop is written in C/C++ and call the game logic which is Python, and renderer which is C++(I intend to do this with Cython)

  3. The game, loop and renderer are written in C++, only the logic is written in Python

I personally dislike the third option because I've tried it before and designing the abstraction layer between C++ and Python is a bit of a hassle compared to the other way round.


Considering each approach what would be the incurred overhead of 1 and 2 compared to 3, and 1 compared to 2?

share|improve this question
I would suggest looking into Pyglet. It's a lightweight library that runs it's OpenGL calls on the video card. You can even write straight C OpenGL calls in it. Performance is very good. – FryDay Dec 16 '13 at 18:41
up vote 2 down vote accepted

Option 1: If you are familiar with python this would be the best approach since in average the rendering takes 70-80 % and to make that part in python would slow the game to much. However you would want to avoid doing any low level 3d from python (like computing stuff on vertices) so the c++ part has support lots of features out of the box , without the need to go under the hood. I would recommend choosing Cinder for the c++ part. It has lots of nice features and support for new c++ standard.

Option 2: This would give no real world advantage over option 1 , it's just not worth the effort to split the code in all the random places.

Option 3: This would be the professional approach where performance is critical. If you don't have strong c++ skills you will probably loose this battle. One advantage of this is that you can keep a hard limit on the stuff that the python code can do so you keep the project safe within it's requirements.

As a side note, you mentioned that you want to do rendering as fast as the hardware allows, and i think that even if you go for option 1 you can still achieve that. If the game logic is done properly then there is no need to move any of that to c++ it can be written entirely in python.

share|improve this answer
I do have C++ experience and have implemented option 3 before(with lua) however designing the abstraction layer basically involves making an entire API for the script to access. – vitiv Nov 28 '13 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.