Performance gain from Python to C++

Hello out there !

I am really interested in Panda 3D and think about coding a game in Python and
then transfering all or part of it to C++ API- Panda to increase performance.

  1. Is the conversion from Python to C++ easy ?
  2. How much speed will I gain if the application is 3D-graphics intensive ?

regards, Oliver

I don’t know how easy it is to port from Python to C++ in Panda, but it is possible and there would be a performance gain in certain cases. I think code with heavy processing and/or loops would probably benefit. Graphically intensive code should be C++ only and typically (or ideally) Python should be used to script game logic, interfaces, loading etc.

I’m not expert but that’s my take on it.

P.S. - please don’t cross post your question twice. 8)

We have found that the vast majority of game logic can be coded in Python and left there. Compared to the time spent drawing triangles in C++, the time spent moving objects in the world in Python is usually miniscule, so rewriting the whole thing in C++ won’t actually gain you very much in the big picture, and isn’t worth the trouble (you could be spending that time adding more game features).

On the other hand, we do occasionally write parts of the game in Python that are really better suited for being written in C++. These are typically tasks that require lots of math work per-frame (such as custom code to handle camera movement, for instance). We find that moving these small tasks to C++ can be a win. It’s usually not difficult to translate Python to C++, but you do have to understand that you will be completely rewriting the code.

The PStats tool that ships with Panda can be a useful tool to show you how much time you’re spending in Python as a whole, and in each task within Python, relative to your entire frame; this can help you determine how worthwhile it is to translate a particular task to C++. And 99% of the time, the answer is “not worthwhile”–Python is a good language in itself.


Thx for the answers !

I will look into Panda 3D to c if it suits the game I have in mind.
Especially, I might need to push around many low-poly objects on screen.
(Lets say up to 100 objects with 20 polys each plus floor textures onscreen).
Do you think this is possible ?

I did post THIS message only once. I posted another question in two forums
because it had to do both with compilation from source and installation.

regards, Oliver

Sorry - I thought the titles were the same. :blush:

No problem ! :wink:

What do u think - is Panda plus Python fast enough to push around 100
models of 20 polys each around (All onscreen plus some floor textures) :question:

thx , oliver

100 moving objects should not present a problem for Python. The number of vertices per object, of course, is irrelevant to Python (although it will make a difference to your graphics card).


Hello ,

When trying to decide if panda was suitable to my technical need, i performed the following test on my computer
(Athlon 1,8 -512 RAM-TI4200 with 128MB ram , no overclocking)

-create a row of 100 pandas (the model from the demo who can walk and eat)

  • one panda out of two have walk animation
  • the other panda have eat animation
    -the panda are in the city scenary (available from download from the website)
  • three tasks are running backward
  • one for each panda is making it walk front turn walk back turn …
  • one for the row is making circle around the vertical axix
  • one for the row is making it go up and down alng the vertical axis

In openGL rendering , windowed 800*600 i get between 50 and 65 fps
(depending if i show direct tool or not)

Thank u both for the answers.

That sounds like I can indeed use panda for the game I have in mind.

Regards, Oliver