Another thing you could do is create your own mini-array Cython class. E.g.: A 
class "DoubleArray" has C fields "ptr" and "len", and a subclass 
"PyDoubleArray" allows initializing those using a Python list (and managing the 
memory needed to hold the converted result etc.). That's about 20 lines, 
nothing fancy...

So from the unit tests you'd pass inn "PyDoubleArray" and from Cython code raw 
"DoubleArray".

Your methods could then be "cpdef" and use the same interface.

Doesn't quite work out if you want to create C-callable code though.

Dag Sverre Seljebotn
-----Original Message-----
From: Magnus Lie Hetland <[email protected]>
Date: Friday, Jan 2, 2009 10:31 pm
Subject: Re: [Cython] Array parameter...
To: [email protected]: [email protected]

On Jan 2, 2009, at 22:11 , Robert Bradshaw wrote:
>
>> The standard way to do things now is to write a cdef function that
> takes a double* and length argument, then write a python wrapper for
> testing.
>
>Yeah, that's what I had planned. Sounds like a good solution, I guess.  
>(Now I just need a naming convention to separate the two ;-)
>
>> You could also look at using NumPy arrays with the buffer
> interface, depending on what you're doing.
>
>Indeed. I played with that a bit; it might be the best bet, perhaps  
>(although sticking with only Cython has the advantage that I can ship  
>the generated C code, and the user needn't install anything beyond  
>Python).
>
>-- 
>Magnus Lie Hetland
>http://hetland.org
>
>
>_______________________________________________
>Cython-dev mailing list
>[email protected]
>http://codespeak.net/mailman/listinfo/cython-dev
>

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to