views:

640

answers:

3

I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to keep the codebase in Python for easy updates.

What I'm wondering is how much slower should I expect things to go? I realize this is vague and open ended, but I just need a sense of what to expect. Will drawing 500 circles bog down? Will it be noticeable at all? What are your experiences?

+1  A: 

IMHO, main bottleneck will be the data structures you are going to use for representing the network graph. I have coded a similar application for tracing dependencies between various component versions in a system and graphics was the last thing I had to worry about and I was certainly drawing more than 500 objects with gradient fills for some of them!

If you are getting bogged down, you should checkout using PyGame for drawing things.

Suraj Barkale
Thanks. I gave you the checkmark because you gave a use case that's almost exactly what I plan to do.
Soviut
+1  A: 

In my experience, doing things the naive way (drawing each object to the screen) will bog down in Python quicker than C++. However, with Python it's going to be a lot quicker and less painful to code it the clever way (see for example PseudoDC), which will blow the naive C++ implementation out of the water.

I agree with suraj. above that PyGame may be a good choice, depending on how graphics-intensive the app is, compared to the convenient wxPython stuff you'll be giving up.

Ryan Ginstrom
what's PseudoDC?
1800 INFORMATION
Good comment. I added a link to the docs. You can also find an example in the wxPython demo.
Ryan Ginstrom
A: 

For drawing, people have suggested PyGame. I like PyGame, its easy to work with and works well. Other choices would be Pyglet, or using PyOpenGL (you can most likely draw to a wx widget too, though I've never done it).

Personally, I'd do it in Python using whatever library I'm most familiar with (in my case, I'd use pygtk and cairo) and worry about performance only when it becomes a problem - then profile and optimize the bottleneck, if its Python code thats slow, I'll know which bits to run in C instead.

Dan