Hi,

Brian Granger wrote:
> In a function it is often necessary to allocate dynamic memory.  It is
> desirable to have something that it 1) fast and 2) doesn't lead to
> memory leaks if something goes wrong and 3) is easy to debug.
> 
> Proposal
> -------------
> 
> The main idea (Lisandro came up with this) is to build these
> capabilities into cython itself by introducing the following syntax:
> 
> cdef foo(size):
>   cdef double a[size]    # This is like the dynamic arrays in C99
>   # do stuff with a, but don't worry about deallocating the memory!!!

I actually like the syntax as it is rather clear that this is memory local to
the function. It's just like having it allocated on the stack, with the
exception that it depends on run-time state. So the automatic deallocation at
function exit is not unexpected.

Regarding PyMalloc, I think it's a good idea to use it, but you have to take
care in "nogil" functions. They require plain malloc()/free() calls.

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to