On Mon, May 4, 2009 at 2:37 PM, Robert Bradshaw
<[email protected]> wrote:
> On May 4, 2009, at 11:33 AM, Stéfan van der Walt wrote:
>
>> Hi all,
>>
>> Is there a way to tell Cython if you are using a homogeneous list?
>> E.g.
>>
>> cdef list[int] my_list
>>
>> my_list.append(1)
>> my_list.append(2)
>>
>
> No, there's not. It would be nice, but it would be hard to control
> what people stick in the list (e.g. if you pass it off to another
> routine). You might want to look at using NumPy arrays, which can
> store lists of actual c ints, etc.

In addition to NumPy arrays, you might consider using array.array
which support 'append' and other list methods.  They're basically
homogeneous lists within the Python standard lib.  A bit more flexible
but not as powerful as NumPy arrays.

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

Reply via email to