Converting C++ array into Python

Larry Bates larry.bates at websafe.com
Wed Oct 12 15:07:27 EDT 2005


Yes, I'm normally calling .DLL function with a defined API and
memory layout.  May not be optimal, when you don't have the
C code available and the data structure is part of the API it
works just fine.

-Larry Bates

Jorgen Grahn wrote:
> On Wed, 12 Oct 2005 11:13:52 -0500, Larry Bates <larry.bates at websafe.com> wrote:
> 
>>Like others, without more information on what you have tried we are
>>just guessing.  Many times I've used the struct.unpack() module to
>>unpack C "arrays" into python objects.
> 
> 
> In that case, it sounds like you make yourself depend on the memory layout
> of those C arrays -- generally a very bad thing to do.
> 
> 
>>Don't know if this will help,
>>but thought I'd pass it along.  Post some code and we can help more.
> 
> 
> Yes. Or at least tell us what the /type/ of that array is.
> 
> I assume it's 'Foo thearray[]', in which case you usually would return it as
> a Python list of whatever Python data structure you encode a Foo into --
> might be a tuple, or an integer, or a full-blown class of some kind, or ...
> 
> /Jorgen
> 



More information about the Python-list mailing list