Ashish,

if you really need it to be a `list` in python, then there is no way
around it, you have to copy it. If you just need it to behave like a
list, then that is possible. Just export your struct to python and
implement methods such as __get__(),  __set__(), __len()__, __eq__(),
...

You may also read up on boost python indexing suite (optionally
version 2) and see if that helps you to expose all these methods. If
you write you class very much like std::vector, then the indexing
suite can be of great help. Otherwise, just export those functions by
hand.

-Holger


On Fri, Jul 26, 2013 at 11:16 PM, Ashish Sadanandan
<ashish.sadanan...@gmail.com> wrote:
> Ashish Sadanandan <ashish.sadanandan <at> gmail.com> writes:
>
>>
>> I have a struct that contains a C-style array data member. I'd like to have
>> this struct exposed to Python, and this data member be accessible as a tuple
>> in Python.
>>
>> struct S
>> {
>>   char arr[10];
>> };
>>
>>
>> So the question is, how can I expose that C-style array data member to
>> Python as a tuple?
>>
>
> I screwed up the question. I actually need a list, not a tuple, since it
> needs to be modifiable on the Python side. The rest of the question remains
> the same; except I should also mention that the array in question is 4128
> chars long, not just 10. So copying it is not as trivial as the question
> first implies.
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig@python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to