Performance issues with Pyglet? Alternatives?

Started by
6 comments, last by BurrickSlayer 10 years, 9 months ago

I'm going to ask a question here I asked over at StackOverflow just because I'm not really getting an answer over there. :/

Basically I've been avoiding Python for my game just because its supposed to have a lot of performance issues. I actually bought a book today that demonstrates how to do some basic programming with C and the SDL/OpenGL libraries (partially just because I've always wanted to learn C anyway, for fun) when I noticed somewhere Pygame is actually backed up by having most of the SDL be in C, and it just acts as a wrapper.

I heard Pyglet was a good tool for using OpenGL which I'd rather use, both for specific features and just general performance from being hardware accelerated, but I noticed that it was written in "pure" Python. Is Pyglet known for having performance issues? Has anyone here used it to any great effect?

And since I'm going to be learning it anyway, if Pyglet DOES have issues since its all Python, what are my best alternatives for getting OpenGL in Python with maybe some C to back up the performance?

Thanks!

AniMerrill, a.k.a. Ethan Merrill

Advertisement

There are not really general performance issues with languages, you always need to consider the context. Even most hi-performance engines like UDK use slower scripting languages ingame to perform certain tasks. So you need to define your goal first and then choose a suitable language (there will be always a lot of options). If performance would be all we need, all games would be most likely writting in asm by a handful of uber-experts smile.png

If you want to learn this language with a small test project/game, then just do it. Many performance issues come from using wrong data structures, bad coding styles or badly suited algorithms and not directly from the language. happy.png

AFAIK you can use OpenGL via PyGame as well, right?

Is Pyglet known for having performance issues? Has anyone here used it to any great effect?

I've never used it, but it was initially made as a university project by a guy with no games industry experience, so I'd expect performance to be typical of "academia" ;) tongue.png

If you need to optimize the code you must first learn to profile, then you can use cython: http://docs.cython.org/src/quickstart/cythonize.html

But I believe you will hardly need this, most engines use script language to access their core (that are written in C or C++) and perform quite well.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

Note that pygame and pyglet are not game engines. They are APIs. A full engine with bindings to python could perform very well. Check out PyOGRE (not a full game engine, but a powerful 3D graphics engine) and Panda3D (full game engine).

I've never used it, but it was initially made as a university project by a guy with no games industry experience, so I'd expect performance to be typical of "academia" ;) tongue.png

I wrote a planet renderer with it...

But then again, the planet renderer is pretty much all GPU-side. One could probably get away with write the CPU-side portion in bashscript.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


Basically I've been avoiding Python for my game just because its supposed to have a lot of performance issues.

I've read somewhere that Python is, on average, around 20x slower than C, with the "worst case" scenarios reaching as high as 100x.

These measures, if true, seem unforgivably high, but in most cases, I think it basically reduces down to "the speed of light vs the speed of sound" argument: The speed of sound is ~880991x slower than the speed of light, but this is only obvious in specific circumstances, and it's only then that it actually matters.

So, if I were you, I would consider theoretical execution speed to be irrelevant, until it actually becomes a problem (which might be never).

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+
If performance becomes an issue, you could give PyPy a try. Of course, you could give PyPy a try without having any performance issues, as well. smile.png

According to the PyPy compatibility page pyglet works fine with PyPy. This is only true for pyglet 1.1.4, though, as PyPy doesn't support Python 3 yet.

Here is the most recent status update for the py3k branch of PyPy (the branch that adds support for Python 3) in case you're interested:
http://morepypy.blogspot.se/2013/06/py3k-status-update-11.html

This topic is closed to new replies.

Advertisement