I've been writing a [http://www.freenet.org.nz/y4m wrapper] for the [http://mjpegtools.sourceforge.net Mjpegtools] yuv4mpeg API, which contains several extension classes. Even though I provided a __del__ method which free()**s all **malloc()**ed buffers, memory was leaking like a firehose. I realised the **__del__ methods were not being invoked.
But deeper within the [http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Pyrex documentation] is a little mention of[http://ldots.org/pyrex-guide/5-python-wrapper.html#begin constructors and destructors]. With extension types, it seems you have to free your buffers in a __dealloc__ method instead. Result? No more memory leaks.