Hi,

just a couple of additional comments here.

I do see the advantage of the "with" proposal, but that would require us to
have a couple of keywords for things like "carray" that the compiler would
have to recognise.


Dag Sverre Seljebotn wrote:
> If you want a different memory allocator, simply use a different 
> function than carray...

If you want a different allocator than used by the proposed syntax, don't use
the syntax. IMHO, it's perfectly ok if syntactic sugar helps in most cases but
not all.


> 3) Long-term Python users with very little C experience might end up 
> doing something like
> 
> cdef double a[size]
> # fill in a
> return a

This is a problem that could be caught in the compiler. Returning a local
non-scalar/non-pointer variable could just be forbidden. And the remaining
case where you return an explicitly created pointer to the same thing is just
stupidity.


> 3) Just an overall comment: I personally think NumPy arrays are 
> excellent for this. I'd have no problems personally with using a NumPy 
> array only in order to allocate memory and then pass that memory on to a 
> C library for instance. (The problem is, I suppose, having to depend on 
> the NumPy library...though investing effort in creating a garbage 
> collected array type when NumPy already has that seems too much like 
> reinventing the wheel to me.) This will become more convenient than 
> today if Cython grows better NumPy support.

Requiring NumPy for what the proposal tries to achieve clearly looks like
overkill to me.


>> 3) The trick is to make sure that free(private_ptr) is called when the
>> function's scope is finished.

That's actually trivial, as the generated function body always goes through
the same (or a limited number of different) cleanup code sequences at the end.

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

Reply via email to