Reputation: 355
I have a Cython function like cdef generate_data(size)
where I'd like to:
size
C
) function to populate the array using array ptr and sizeI have seen many approaches on the internet but I'm looking for the best/recommended way of doing this in my simple case. I want to:
I'm using Cython 0.20.
Upvotes: 2
Views: 3880
Reputation: 60147
For allocating memory, I have you covered.
After that, just take a pointer (possibly at the data
attribute if you use cpython.array.array
like I recommend) and pass that along. You can return the cpython.array.array
type and it will become a Python array.
Upvotes: 1