Noticed METH_O isnt used anywhere in pygame, this avoids creating a
tuple only to get a single PyObject back out with PyArg_ParseTuple().
Attached an example patch below.
Heres a list of places this could be changed (from svn trunk).
functions that are not likely to be called often don't matter with
this so much.
./src/base.c:102: if (!PyArg_ParseTuple (arg, "O", &quitfunc))
./src/font.c:359: if (!PyArg_ParseTuple (args, "O", &text))
./src/font.c:398: if (!PyArg_ParseTuple (args, "O", &textobj))
./src/mixer.c:919: if (!PyArg_ParseTuple (arg, "O", &file))
./src/movie.c:440: if (!PyArg_ParseTuple (arg, "O", &file))
./src/movieext.c:548: if(!PyArg_ParseTuple(arg, "O", &file))
./src/music.c:251: if(!PyArg_ParseTuple(args, "O", &file))
./src/music.c:303: if (!PyArg_ParseTuple (args, "O", &file))
./src/rect.c:291: if (!PyArg_ParseTuple (args, "O", &list))
./src/rect.c:333: if (!PyArg_ParseTuple (args, "O", &list))
./src/rect.c:408: if (!PyArg_ParseTuple (args, "O", &list))
./src/rect.c:449: if (!PyArg_ParseTuple (args, "O", &list))
./src/rect.c:499: if (!PyArg_ParseTuple (args, "O", &dict))
./src/rect.c:534: if (!PyArg_ParseTuple (args, "O", &dict))
./src/surface.c:810: if (!PyArg_ParseTuple (args, "O", &list))
cases with type checks...
./src/_numericsndarray.c:38: if (!PyArg_ParseTuple (arg, "O!",
&PySound_Type, &chunkobj))
./src/_numericsndarray.c:104: if (!PyArg_ParseTuple (arg, "O!",
&PyArray_Type, &arrayobj))
./src/_numericsurfarray.c:40: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:110: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:152: if (!PyArg_ParseTuple(arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:198: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:302: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:442: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:546: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surfobj))
./src/_numericsurfarray.c:1067: if (!PyArg_ParseTuple (arg, "O!",
&PyArray_Type, &arrayobj))
./src/display.c:952: if (!PyArg_ParseTuple (arg, "O!",
&PySurface_Type, &surface))
./src/event.c:774: if (!PyArg_ParseTuple (args, "O!", &PyEvent_Type, &e))
./src/fastevent.c:220: if (!PyArg_ParseTuple (args, "O!", &PyEvent_Type, &e))
./src/mixer.c:530: if (!PyArg_ParseTuple (args, "O!", &PySound_Type, &sound))
./src/pixelarray.c:267: if (!PyArg_ParseTuple (args, "O!",
&PySurface_Type, &surfobj))
Heres an example patch.
Index: src/event.c
===================================================================
--- src/event.c (revision 1744)
+++ src/event.c (working copy)
@@ -765,15 +765,14 @@
}
static PyObject*
-event_post (PyObject* self, PyObject* args)
+event_post (PyObject* self, PyEventObject* e)
{
- PyEventObject* e;
SDL_Event event;
int isblocked = 0;
-
- if (!PyArg_ParseTuple (args, "O!", &PyEvent_Type, &e))
- return NULL;
-
+
+ if (!PyObject_TypeCheck((PyObject *)e, &PyEvent_Type))
+ return RAISE (PyExc_ValueError, "post requires 1 event
argument");
+
VIDEO_INIT_CHECK ();
@@ -933,7 +932,7 @@
{ "clear", event_clear, METH_VARARGS, DOC_PYGAMEEVENTCLEAR },
{ "get", event_get, METH_VARARGS, DOC_PYGAMEEVENTGET },
{ "peek", event_peek, METH_VARARGS, DOC_PYGAMEEVENTPEEK },
- { "post", event_post, METH_VARARGS, DOC_PYGAMEEVENTPOST },
+ { "post", event_post, METH_O, DOC_PYGAMEEVENTPOST },
{ "set_allowed", set_allowed, METH_VARARGS, DOC_PYGAMEEVENTSETALLOWED },
{ "set_blocked", set_blocked, METH_VARARGS, DOC_PYGAMEEVENTSETBLOCKED },