Python vs Speed

So after a few days playing around with python I noticed a few interesting things:

1) PyPy is not always the fastest!

PyPy is an version of Python with a JIT compiler that is supposed to speed-up python code dramatically. It especially is good at optimising loops but has trouble with python modules that are not pure python, but have C/C++ backend libs.

Unfortunately in my case both PyGLET and PyMunk are backed by C/C++ and the event loop of my game is handled by PyGLET and calls events on the python code.

This causes PyPy to not perform as well as CPython in my case.

2) CPython performance is weird???

With my very simple early prototype I am getting weirdly inconsistent frame-rates between runs of the exact same code.

While I usually get a nice smooth 60fps, every now and then it will only run at 20fps for no apparent reason.

This raises the possibility that the finished game will not perform as well as I would like and makes me consider dropping python in general.

Of course that has its own set of problems, while the chipmunk code can be fairly easily ported to c++, changing the windowing/graphics library to something like SDL will be a bit of a pain.

Here we go again!

After a fairly substantial break that started off with an attempt to make a compiler for a custom language, I have decided to come back to the #1GAM competition and have another go.

The theme for this month is Resolution.

The game idea that I have come up with is a platformer game where your character starts off as a single pixel (scaled up so its visible) with no memory of who you are and what happened to you.

By collecting pixels throughout the levels you will gain “resolution” and recover your memories.

This time I will be using python as the language and the pyglet window/graphics/sound library.

I am also considering the pymunk wrapper for the chipmunk physics library.

I recorded a video of a little test that I did with the sprites that I am going to use (full resolution) you can find here: