Saturday, July 18, 2009

pyweek #9 - week games, not weak games.

Pyweek is a game^H^H^H^H competition where you make a game in a week. You've probably heard of it(in which case ignore the rest of the words below, and above).

Some people call them sprints, other people call them jams, and other people call them battles, or game development competitions.

Pyweek is not really a battle, or Nerd-Jam® and not even really a competition, but a big-warm-hug of a week: making games with around 100 people from all over the world.

You get to throw off the shackles of your boring web development job, and be creative (kinda like fight club, but with zombies). There's so much energy during the week, with lots of feed back, ideas and screen shots flying this way and that. It's a bit intoxicating.

Individuals, and teams can take part. Some crazy people even take part in both a team, and do a solo entry.


Friday 2009/07/31Registration open
Sunday 2009/08/23Theme voting commences
Sunday 2009/08/30Challenge start
Sunday 2009/09/06Challenge end, judging begins
Sunday 2009/09/20Judging closes, winners announced

Thursday, July 09, 2009

python3 C API - simple slicing (sq_slice) gone.

Python3.x silently removed simple slicing support from the C API.

The problem is, python3 doesn't give you a warning it won't be used... it compiles fine... just your slicing tests will fail.

Since it's not documented anywhere, I will briefly mention a solution. Thanks to Campbell Barton for the idea.

You can reuse your old sq_slice function and create a new function in a PyMappingMethods. You can also reuse your sq_length in the MappingMethods directly with no changes.

mp_subscript is it's name.

Here is an example function from pygame.Color where it reuses _color_slice from the old simple slice function.
static PyObject * _color_subscript(PyColor* self, PyObject* item) {

#if PY_VERSION_HEX < 0x02050000
if (PyInt_Check(item)) {
Py_ssize_t i;
i = 0;
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);

if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
i += PyList_GET_SIZE(self);
return _color_item(self, i);
if (PySlice_Check(item)) {
int len= 4;
Py_ssize_t start, stop, step, slicelength;

if (PySlice_GetIndicesEx((PySliceObject*)item,
len, &start, &stop,
&step, &slicelength) < 0)
return NULL;

if (slicelength <= 0) {
return PyTuple_New(0);
else if (step == 1) {
/*NOTE: reuse your sq_slice method here. */
return _color_slice(self, start, stop);
else {
"slice steps not supported");
return NULL;
else {
"Color indices must be integers, not %.200s",
return NULL;

pygame 1.9.0 has support for python2.4 through to python3.1 now. It still mostly works with 2.2 and 2.3 too, but we stopped caring about those versions with this release. So it seems possible to make complex packages which contain both C extensions, and python parts that support many different versions of python. Not everything is ported to python3.x yet, hopefully that will come in a future pygame release.

More python3.x c porting tips are being collected in the wiki at Searching on google is becoming more useful as people discover the C API differences themselves. If you've got any other C API porting tips, or links to peoples experiences please leave them on the wiki too! :)

Wednesday, July 08, 2009

Google OS.

Finally our overlords are giving us google chrome OS. I don't usually like to repeat google-pr, especially vapour^H^H^H^H^Hcloud-ware... but this is interesting.

Actually the article isn't interesting, except 'google are going to release another OS'. No technical details... and no comic book.

Not sure if it'll be anywhere near as good as the latest from Debian/Ubuntu, MS or Apple.

OS user interfaces are way ahead of anything google has made on the web... and game interfaces are way ahead of OS interfaces.

ps. this is the second OS google has released recently. android is the previous one (not yet hugely successful).