Auto free Buffer objects in C API?
Stuart D. Gathman
stuart at bmsi.com
Mon Jul 7 16:04:20 CEST 2003
On Thu, 03 Jul 2003 21:44:27 -0400, David M. Cooke wrote:
> This is a bit ugly, as it depends on internal details. Another, cleaner,
> method is to define an object which obeys the buffer protocol, and
> handles destruction like you want. (This is annoying, as you'll end up
> copying all the code in bufferobject.c).
So annoying, in fact, that I will continue to make extra copies of the
buffer until such time as:
a) Python gets a PyBuffer_FromCObject(PyObject *,int len) method.
b) Profiling reveals the extra copies to be a major bottle neck. The
extra memory allocation is not a problem because the library spends most
of its time moving the data between two buffers while processing it.
BTW, the application is wrapping DSpam for Python. You can download the
dspam module from:
More information about the Python-list