Re: C extension - new and init functions

2008-11-17 Thread Paul Moore
On 17 Nov, 09:40, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Paul  Moore <[EMAIL PROTECTED]> writes: > > > OK, but that allocates the initial buffer, which I will then > > throw away. > > Why don't you use a constructor argument that allows specifying > the initial buffer size? That's an option, b

Re: C extension - new and init functions

2008-11-17 Thread Hrvoje Niksic
Paul Moore <[EMAIL PROTECTED]> writes: > OK, but that allocates the initial buffer, which I will then throw > away. Why don't you use a constructor argument that allows specifying the initial buffer size? > In practice, this isn't a significant issue (the overhead of one > allocation and one de

C extension - new and init functions

2008-11-16 Thread Paul Moore
I have a C extension type, "Pattern", where my type manages a dynamically allocated memory block (of "instructions", the details aren't important). The basic constructor builds a pattern with a single instruction ("End") as follows: static PyObject * Pattern_new(PyTypeObject *type, PyObject *args